Powershell Switch statement with multiple values
Solution 1:
$myNumber = 3
$arrA = 1, 3, 5, 7, 9
$arrB = 2, 4, 6, 8, 10
switch ($myNumber) {
{$arrA -contains $_} { write-host "Odd" }
{$arrB -contains $_} { write-host "Even" }
}
Solution 2:
In your case you can simply use
switch ($myNumber) {
{ $_ % 2 -eq 1 } { "Odd" }
{ $_ % 2 -eq 0 } { "Even" }
}
An actual attempt to model what you can do there in VB would probably be something like
switch ($myNumber) {
{ 1,3,5,7,9 -contains $_ } { "Odd" }
{ 2,4,6,8,10 -contains $_ } { "Even" }
}