Reputation: 23
Trying to get my switch statement working with an "-or" operater in it.. What am i doing wrong?
Code:
PS C:\Windows\system32> $a = 1031
PS C:\Windows\system32> switch ($a) {1031 {write "True"}}
True
PS C:\Windows\system32>
PS C:\Windows\system32>
PS C:\Windows\system32> switch ($a) {((1031) -or (2055)) {write "True"}}
PS C:\Windows\system32>
Upvotes: 2
Views: 469
Reputation: 126922
You need to use a scriptblock, $_
is the value you're switching on (e.g $a):
switch ($a)
{
{$_ -eq 1031 -or $_ -eq 2055} {write "True"}
}
Upvotes: 3