我试图通过自定义属性employeeId
在AD(windows 2008 r2)中找到重复的对象Get-ADUser -Filter {(employeeID -like "*")}
| Select-Object Enabled, ObjectClass, Name, UserPrincipalName, SamAccountName, employeeID
|
ForEach-Object {
$obj1 = $_
ForEach-Object {
if($_.employeeID -eq $obj1.employeeID){
}
}
}
| Export-Csv C:\Users\user\Desktop\mployeeId_is_duplicate.csv
感谢
答案 0 :(得分:2)
尝试使用group-object并选择所有具有Count>的实体2像这样:
Get-ADUser -Filter {(employeeID -like "*")} -property employeeID |Group
employeeid | ? {$_.Count -ge 2} | select -ExpandProperty group | Select-
Object Enabled, ObjectClass, Name, UserPrincipalName, SamAccountName,
employeeID | Export-Csv C:\Users\user\Desktop\mployeeId_is_duplicate.csv