I want to delete computer accounts in an OU that do not exist in a vmware folder....
Step 1. Compare.
$ad = Get-QADComputer -SearchRoot 'domain.lan/Test-NoGPO'$vmware= Get-VM -Location VDI_RemoteAccessWrite-Host "AD" $adWrite-Host "VMWARE" $vmwareCompare-Object $ad $vmware
That gives me this output:
AD DOMAIN\DSTASA1$ DOMAIN\SXCH100$ DOMAIN\SKFB111$ DOMAIN\FAKEPC$
VMWARE vstaq16 vstaq18
InputObject SideIndicator
----------- -------------
vstaq16 =>
vstaq18 =>
DOMAIN\DSTASA1$ <=
DOMAIN\SXCH100$ <=
DOMAIN\SKFB111$ <=
DOMAIN\FAKEPC$ <=
I need the output of the first 2 commands to be the same... preferably just the "name" of the pc. On the compare-object line I tried using $ad.Name and $vmware.Name but that errors and says that it's null when the script runs...
How can I sanitize these lists and end up with a list of machines that aren't in both places? (to later be deleted with some other commands, not relevant here)
You were halfway there when you tried with the Name property.
But you have to store all computernames in 1 array and all the VMnames in another array.
Then you can compare the 2 arrays.
Something like this
$ad = Get-QADComputer -SearchRoot 'domain.lan/Test-NoGPO' | %{$_.Name}
$vmware= Get-VM -Location VDI_RemoteAccess | %{$_.Name}
Compare-Object $ad $vmware
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You were halfway there when you tried with the Name property.
But you have to store all computernames in 1 array and all the VMnames in another array.
Then you can compare the 2 arrays.
Something like this
$ad = Get-QADComputer -SearchRoot 'domain.lan/Test-NoGPO' | %{$_.Name}
$vmware= Get-VM -Location VDI_RemoteAccess | %{$_.Name}
Compare-Object $ad $vmware
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You're the man. I don't really understand why my first attempt didn't work, but all is well. Now to refine my compare command and start deleting accounts.