Last active
October 10, 2017 05:42
-
-
Save keithga/a4568ce5bdfca8b8b12921e158dc56ba to your computer and use it in GitHub Desktop.
TEst switches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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