Reputation: 65
I'm new to Powershell, and the title pretty much points out what I'm trying to do. I have here two .CSV files that includes the usernames of a group and the other an OU. I need to compare the userlist of the group and the OU then proceed with deleting the duplicates from the group in AD.
I've been googling around, and have found a few leads, but me being a new Powersheller I have not been able to combine what I've found into a working command that does what I want it to.
Here is the format of the .CSV files that I want to be compared. Samaccountname (the header) should not be compared.
"samaccountname" "tb2" "tb3" "tb4"
Upvotes: 1
Views: 12531
Reputation: 65
$Group = import-csv -path C:\Output\Test.csv
$OU = import-csv -path C:\Output\DomainUsers.csv
Compare-Object $Group $OU -property samaccountname -IncludeEqual | where-object {$_.SideIndicator -eq "=="} | Export-csv C:\Output\Difference.csv –NoTypeInformation
is the code I was looking for.
Upvotes: 3