I have two list, A and B and I needed the element of the B list not present in the A list to be in a created list C in Powershell. (list or array)
A | B | C |
---|---|---|
One | One | Second |
Two | Two | |
Three | Three | |
Third | Second | |
Fourth | third |
In this example in C there is the word Second as it is not present in A list. So it is not the difference between two list, it is one to another, but not the other way around.
I have tested the Compare-Object
command but it will exclude the element that are not in B but in A and the ones that are in B but not in A. Which is not what I am looking for.
I also tried something like this :
foreach ($elem in $A) { if ($B -contains $elem) { "there is a match" } }
But it didn't work as I want.
I'm a bit lost a this point.