I basically want to do this:
switch($someString.ToLower())
{
"y", "yes" { "You entered Yes." }
default { "You entered No." }
}
I basically want to do this:
switch($someString.ToLower())
{
"y", "yes" { "You entered Yes." }
default { "You entered No." }
}
You should be able to use a wildcard for your values:
switch -wildcard ($someString.ToLower())
{
"y*" { "You entered Yes." }
default { "You entered No." }
}
Regular expressions are also allowed.
switch -regex ($someString.ToLower())
{
"y(es)?" { "You entered Yes." }
default { "You entered No." }
}
Powershell Switch documentation: http://technet.microsoft.com/en-us/library/ff730937.aspx
switch($someString.ToLower())
{
{($_ -eq "y") -or ($_ -eq "yes")} { "You entered Yes." }
default { "You entered No." }
}
Supports entering y|ye|yes and case insensitive.
switch -regex ($someString.ToLower()) {
"[yes]" {
"You entered Yes."
}
default { "You entered No." }
}