Operator Scope of Action:
Operator First Added:
Operator Last Altered:
This calculates the intersection of two List or Sets, the chained Set and the set in the aSet argument The .intersect() test is generally intended for use with Set-type data but will work with Lists, though the result is always a Set.
$MySet = $MySetA.intersect($MySetB);
$MySet = $MyList1.intersect($MyList2);
The result is a Set of all items in both $MySetA and $MySetB, or in the second example in both $MyList1 and $MyList2. As the result is always a set, any source list items are de-duped in the output.
No special code is needed to find items in one set but not the other:
$MySetC = $MySetA - $MySetB; gives items only in $MySetA
$MySetC = $MySetB - $MySetA; gives items only in $MySetB
Use with Lists
Subtracting a Set from a List results in only one instance of each Set item being removed. Subtracting a List from a List each instance of a value in the second list is removed so multiple source List entries may be removed.