Skip to content

Instantly share code, notes, and snippets.

@Sambardo
Created February 28, 2018 19:26
Show Gist options
  • Save Sambardo/6201cea224385a1179f84caf8289d6ec to your computer and use it in GitHub Desktop.
Save Sambardo/6201cea224385a1179f84caf8289d6ec to your computer and use it in GitHub Desktop.
switch -casesensitive ("hello") #makes it a -ceq
{
"HELLO" {write-host "Uppercase" -ForegroundColor Magenta}
"hello" {write-host "lowercase" -ForegroundColor green}
"h*" {write-host "wildcard" -ForegroundColor Magenta}
}
switch -wildcard ("hello") #makes it a -like
{
"HELLO" {write-host "Uppercase" -ForegroundColor Magenta}
"hello" {write-host "lowercase" -ForegroundColor green}
"h*" {write-host "wildcard" -ForegroundColor Magenta}
}
switch -wildcard -CaseSensitive ("hello") #makes it a -clike
{
"HELLO" {write-host "Uppercase" -ForegroundColor Magenta}
"hello" {write-host "lowercase" -ForegroundColor green}
"h*" {write-host "wildcard" -ForegroundColor Magenta}
}
switch -regex ("hello") #makes it a -match
{
"\w{5}" {write-host "5 characters" -ForegroundColor Magenta}
"\w{6}" {write-host "6 characters" -ForegroundColor green}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment