Goal: Compare 2 lists of computers pulled from 2 different domains. Find the duplcates and pipe them to be disabled in one of the domains.
Problem: When I find the duplicates, they are not simply a computer name, they are like this.. "@{Name=computername}".
Any help is greatly appreciated, I am getting brain fried.
$Properties = @( "name" "Operatingsystem" ) $Select = @( @{n="Name";e={$_."name"}} #@{n="OperatingSystem";e={$_."OperatingSystem"}} ) echo "`nSearching for Domain1 Windows 7 workstations" $Complist1= get-adcomputer -filter * -Properties $properties -SearchBase "DC=domain,DC=com" -server "Server"| Where {$_.OperatingSystem -like '*windows 7*'} | Select name echo "`nSearching for Domain2 Windows 7 workstations" $Complist2 = get-adcomputer -filter * -Properties $properties -SearchBase "DC=domain2,DC=com" -server "server2"| Where {$_.OperatingSystem -like '*windows 7*'} | Select $select $CombinedList = $Complist1+ $Complist2 echo "`nComparing the Domain1 list to Domain2, if a duplicate is found the domain2 workstation will be disabled." #i need help finding the duplicates in the array AND being able to use them using the names to disable them in Domain2. #Below i found online however, the output is in this format and I am at a loss on how to simply get a clean computer name. #Output: "@{Name=computername}" #I need the computername only so I can pipe it into another command to disable the computers. $ht = @{} $CombinedList | foreach {$ht["$_"] += 1} $ht.keys | where {$ht["$_"] -gt 1} | foreach { write-host $_} #Here instead of the write-host, I want to pipe this to a command to disable the computers Your help is apprecia