Check if the Servernames are in both Arrays

Hey guys I have a little problem. I’m doing a Script where I get all the Servers in our Activ Directory Server and then compare them with all the servers that are in our ESX Servers. I want to find out which Servers are in the Active Directory that are not in the ESX Array. Both Arays have the Option "name" with what I’m trying to compair the two Arrays.

I tried doing it with foreach but couldn’t get it to work. Can somebody help?

>Solution :

$a = 1..5
$b = 4..8

Compare-Object -ReferenceObject $a -DifferenceObject $b | Where-Object{$_ -match "<="}

Leave a Reply