One-liner:
foreach ($elem in $A) { if ($B -contains $elem) { "there is a match" } }
But it may be more convenient to count matches:
$c = 0; foreach ($elem in $A) { if ($B -contains $elem) { $c++ } }
"{0} matches found" -f $c
Or if you want to check if arrays intersect at all:
foreach ($elem in $A) { if ($B -contains $elem) { "there is a match"; break } }
Or if you want to check if $A is a subset of $B:
$c = 0; foreach ($elem in $A) { if ($B -contains $elem) { $c++ } }
if ($c -eq $A.Count) { '$A is a subset of $B' }
Finally there's Compare-Object cmdlet which is actually better than all of the above. Example (outputs only elements that are present in both arrays):
Compare-Object -IncludeEqual -ExcludeDifferent $A $B