TEst switches
Function Test-Switch ( [switch] $Test ) { | |
# Correct use of a switch Test (True case) | |
if ( $test ) { | |
"Do Something" | |
} | |
# Bad use of a switch test (False case) | |
if ( $test -eq $null ) { | |
"Never going to do it!" | |
} | |
# Better use of a switch test (False case) | |
if ( -not $test ) { | |
"Don't do it" | |
} | |
} | |
Test-Switch | |
Test-Switch -Test:$False | |
Test-Switch -Test | |
Test-Switch -Test:$True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment