using substitute for "-in" in powershell 2.0

I have a script I wrote using -in and -notin what does not run in powershell 2.0

#this works in powershell 3.0+

#I want to test $i is in (1,2,3)
$i = 1
$a = ($i -in (1,2,3))


#what would be the simplest way to do that in powsershell 2.0
#I came up with the following, but wondered if there is a much
#easier way to do it


$a = $false
$i = 1
switch ($i){
    1{$a = $true}
    2{$a = $true}
    3{$a = $true}
}

Use -contains

PS C:\> $i = 1
PS C:\> $a = (1,2,3) -contains $i
PS C:\> $a
True
PS C:\> $a = (1,2,3) -contains 4
PS C:\> $a
False

Thanks! much cleaner :slight_smile: