Hi i always find it difficult comparing objects in powershell.
Having 2 variables
$var1
user1
user2
user2
And $var2
name status
user2 1
user3 1
user4 0
I want to compare both variables ans return users that are $var2 that are also in $var1
I tried like:
foreach ($user in $var2) { if ( $var1 -contains $user.name ){ write-host $user } }
Also
$var2| foreach-object { if ($_.username -notcontains $var1) write-host $var2 }
But i get nothing in any of the queries...
What am i doing wrong?
Thanks