Powershell: How do I pass variables to switch parameters when invoking powershell at the command line?
This behaviour has been filed as a bug on connect. This is a workaround:
powershell ./test.ps1 -source test.ps1 -dest test.copy.ps1 -test:$true
Use the IsPresent property of the switch.Example:
function test-switch{param([switch]$test) function inner{ param([switch]$inner_test) write-host $inner_test } inner -inner_test:$test.IsPresent}test-switch -test:$truetest-switch -testtest-switch -test:$falseTrueTrueFalse
BTW, I used functions rather than a script so it would be easier to test.