PowerShell: Special Parameter datatype [switch]

# Demo of a simple function to turn lights on and off
function setLight{
param(
[switch]$on,
[switch]$off
)
if($on){write-host "Turn lights ON."}
if($off){write-host "Turn lights OFF."}
}

Output:

Leave a Reply

Your email address will not be published. Required fields are marked *