Skip to content

Instantly share code, notes, and snippets.

@stej
Created January 22, 2011 22:43
Show Gist options
  • Save stej/791578 to your computer and use it in GitHub Desktop.
Save stej/791578 to your computer and use it in GitHub Desktop.
function switchtest {
param([switch]$myswitch)
if ($myswitch) { 'switch is on' }
if (!$myswitch) { 'switch if off' }
#same as above
#if ($myswitch) { 'switch is on' } else { 'switch if off' }
write-host switch value is ([bool]$myswitch) and $myswitch
}
## test
PS> switchtest -myswitch
switch is on
switch value is True and True
PS> switchtest
switch if off
switch value is False and False
@rarous
Copy link

rarous commented Jan 24, 2011

Přijímám patche ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment