Two new operators have been added to PowerShell v3, –In and –NotIn. These are great for folks like me who are used to having this functionality in T-SQL. The syntax is very simple.
$value = 3 if ($value -in (1,2,3)) {"The number $value was here"}
Produces:
The number 3 was here
The not in syntax is just as easy:
$array = (3,4,5,7) if (6 -notin $array) {"6 ain't there"}
Will yield:
6 ain't there
Very simple, but much needed additions to the PowerShell language.
Warning: This post was created using the PowerShell v3 BETA. Changes between now and the final release may affect the validity of this post.