Last active
September 24, 2019 06:45
-
-
Save NReilingh/f503c556f45f032dd01f9de82f4f0ae0 to your computer and use it in GitHub Desktop.
DSC Script Resource $using:Key bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration TestConfig | |
{ | |
Import-DscResource -ModuleName 'PSDesiredStateConfiguration' | |
$Key = "My Value" | |
Node localhost | |
{ | |
Script TestScript | |
{ | |
GetScript = { | |
Write-Verbose "`$Key value is $using:Key" | |
# NoOp | |
} | |
TestScript = { | |
Write-Verbose "`$Key value is $using:Key" | |
if ($using:Key -eq 'Credential') { | |
return $false | |
} else { | |
return $true | |
} | |
} | |
SetScript = { | |
Write-Verbose "`$Key value is $using:Key" | |
# NoOp | |
} | |
} | |
} | |
} | |
TestConfig |
Changing key to mykey seems to work ok, but i get the same result using key as a variable.
Configuration TestConfig
{
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
$myKey = "My Value"
Node localhost
{
Script TestScript
{
GetScript = {
Write-Verbose "`$myKey value is $using:myKey"
# NoOp
}
TestScript = {
Write-Verbose "`$myKey value is $using:myKey"
if ($using:myKey -eq 'Credential') {
return $false
} else {
return $true
}
}
SetScript = {
Write-Verbose "`$myKey value is $using:myKey"
# NoOp
}
}
}
}
TestConfig
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run this script and then inspect the output TestConfig\localhost.mof file. "My Value" is not present.
PowerShell 5.1.18362.145