Powershell - 比较两个.CSV文件并输出重复的名称

Powershell  - 比较两个.CSV文件并输出重复的名称

问题描述:

我是Powershell的新手,标题很多地指出我想要做什么。我在这里有两个.CSV文件,包括组的用户名,另一个OU。我需要比较组的用户列表和OU,然后继续从AD中的组中删除重复的。

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.

我已经搜索,并找到一个很少有潜在客户,但是我是一个新的Powersheller,我无法将我找到的一个工作命令与我想要的工作命令结合起来。

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.

这里是我想要比较的.CSV文件的格式。不应该比较Samaccountname。 http://pastebin.com/bPNf8ExZ

Here is the format of the .CSV files that I want to be compared. Samaccountname should not be compared. http://pastebin.com/bPNf8ExZ

很多提前感谢。

$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

for。