I am building a PowerShell function that builds a hash table. I am looking for a way I can use a switch parameter to either be specified as absent, true or false. How can I determine this?
I can resolve this by using a [boolean] parameter, but I didn't find this an elegant solution. Alternatively I could also use two switch parameters.
function Invoke-API {
param(
[switch]$AddHash
)
$requestparams = @{'header'='yes'}
if ($AddHash) {
$requestparams.Code = $true
}
How would I get it to display false when false is specified and nothing when the switch parameter isn't specified?
