Skip to content

Instantly share code, notes, and snippets.

Last active October 10, 2017 05:42
What would you like to do?
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:$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