Closed guitarrapc closed 6 years ago
Signature should be like this.
configuration present
{
Import-DscResource -ModuleName GraniResource
cScriptOnOSVersion ScriptOnOSVersion
{
Key = "ScriptOnOSVersion"
SetScript = {Set-Item -Path Env:Grani_ScriptOnOSVersion -Value 1}
TestScript = {(Test-Path Env:Grani_ScriptOnOSVersion) -and (Get-Item -Path Env:Grani_ScriptOnOSVersion).Value -eq 1}
ExecuteOnPlatform = "Win32NT"
ExecuteOnVersion = "10.0.16299.0"
When = 'Equal'
}
}
merged!
In default Script resource, it evaluates on when creating .mof then generated constraint value. It means if you using PULL Server, all value in the mof will be static and could not handle by Client. This is because evaluation is done before each client pulling and will not dynamically calculate on client.
In general, this is expected behavior and all resource will only accept constraint value like string or int, then Evaluate on run-time with Custom Resources.
So the solution is simple, just make your dsc resource to handle OSVersion and Script Execution.