Hidden away amongst some of the new language features in PowerShell v3 are two new operators: -in and -notin. Previously you could use -contains, say in an example like the following: does the variable $fruits contain the string ‘Apple’?
$fruits = 'Apple','Orange','Pear' $fruits -contains 'Apple' $fruits -contains 'Banana'
There’s nothing wrong with this approach, but in many examples for me it seemed to be the wrong way around from that I was naturally thinking: is the string ‘Apple’ in the variable $fruits?
With the addition of the -in operator it’s now possible to write it this way:
$fruits = 'Apple','Orange','Pear' 'Apple' -in $fruits 'Banana' -in $fruits