0

I would like to compare 2 arrays $a and $b. Then I would like to get output(array) of those items from $a that has no pair/match in $b.

$a = "audi","mercedes","bmw","lexus"
$b = "audi","mercedes"

Expected output:

$c = "bmw","lexus"

I'm fairly new in Powershell and I couldn't find answer to this anywhere. I tried to use compare-object, but I got output that I didn't know how to convert to Array.

$c = Compare-Object -ReferenceObject $a -DifferenceObject $b
$c 

Is it somehow possible with foreach and if? Thank you for any help!

0 Answers0