, , , , . , -, -. , -, , , , -. Hm, , -: , , - , - , .
$GroupList = Get-Contant c:\temp\Groups.txt
$GroupHash = @{}
$UserHash = @{}
ForEach($Group in $Groups){
$GroupHash.$Group = Get-ADGroupMember $Group
ForEach($User in ($GroupHash.$Group|Where{!$UserHash.($_.distinguishedName)})){
$UserHash.($User.distinguishedName) = Get-ADUser $User.distinguishedName -Server $($User.distinguishedName -replace "^.*?DC=" -replace ",DC=", ".") -Prop Mail
}
}
$GroupHash
, , $UserHash
, , . , , ...
ForEach($Group in $GroupHash.Keys){
$GroupHash.$Group.distinguishedName | ForEach{%UserHash.$_} | Select mail,employeeID,title,department,name | Export-CSV C:\Temp\$Group.csv -NoType
}
CSV C:\Temp .
, , , , , .