Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I basically want to do this:

switch($someString.ToLower()) {     "y", "yes" { "You entered Yes." }     default { "You entered No." } } 
like image 954
Micah Avatar asked Aug 16 '10 13:08

Micah


People also ask

Does PowerShell have a switch statement?

Like many other languages, PowerShell has commands for controlling the flow of execution within your scripts. One of those statements is the switch statement and in PowerShell, it offers features that aren't found in other languages.


1 Answers

switch($someString.ToLower())  {      {($_ -eq "y") -or ($_ -eq "yes")} { "You entered Yes." }      default { "You entered No." }  } 
like image 166
fletcher Avatar answered Sep 22 '22 22:09

fletcher