https://www.sapien.com/blog/2015/11/30/ ... able-file/
While this is a clean workaround for not being able to handle [switch]'s, it still requires a value to be presented..
as such, in my code i have been using the following.
Code: Select all
param
(
[ValidateSet('True', 'False',"", IgnoreCase = $true)]
[string]$SwitchValue = "False"
)
if ($SwitchValue -ne "false") { [switch]$SwitchValue= $true }
else { [switch]$SwitchValue= $false }
however....
If I use the Parameter editor it removes the empty value from the ValidateSet.
Code: Select all
param
(
[ValidateSet('True', 'False', IgnoreCase = $true)]
[string]$SwitchValue = "False"
)
if ($SwitchValue -ne "false") { [switch]$SwitchValue= $true }
else { [switch]$SwitchValue= $false }
Packaged.exe -SwitchValue