What's the PowerShell syntax for multiple values in a switch statement?

Micah picture Micah · Aug 16, 2010 · Viewed 114.9k times · Source

I basically want to do this:

switch($someString.ToLower())
{
    "y", "yes" { "You entered Yes." }
    default { "You entered No." }
}

Answer

fletcher picture fletcher · Aug 16, 2010
switch($someString.ToLower()) 
{ 
    {($_ -eq "y") -or ($_ -eq "yes")} { "You entered Yes." } 
    default { "You entered No." } 
}