<USB.CSV>
Hostname,Username
CNHZPD-TEST1,User1
CNHZLN-01234567,User2
$group = "CN=Enable_CDUSB_CHNHGHWin7&8,OU=Groups,OU=Hangzhou - China,OU=TCS - China,OU=TCS - China,DC=apac,DC=TCS,DC=com" $cmdbdesktop = Import-Csv -Path 'F:IvanHZCMDB~~01--Non GE DST.csv' $cmdblaptop = Import-Csv -Path 'F:IvanHZCMDB~~02--Laptop.csv' $machines = Get-ADGroup -Filter * -SearchBase $group | Get-ADGroupMember | Get-ADComputer -Properties * foreach($adesktop in $cmdbdesktop) { foreach($machine in $machines) { if($machine.name -eq $adesktop.hostname) { $machine | select name , @{N='owner';E={$adesktop.username}} } } } foreach($alaptop in $cmdblaptop) { foreach($machine in $machines) { if($machine.name -eq $alaptop.hostname) { $machine | select name , @{N='owner';E={$alaptop.username}} } } }