我已经看到了很多关于导出组和获取成员的线程,但奇怪的是,两者并没有。基本上,每个广告组及其相应的成员都需要一个.csv文件或类似文件。
我认为这需要在Azure上完成,因为我们有多个域和Office 365 / incloud组(Azure AD列出了所有这些)。
因此,我认为没有将组导出到单个csv文件的另一种方法。
答案 0 :(得分:0)
此PowerShell应该以csv格式(每个组/成员值一行)返回您要查找的内容。
$groups=Get-AzureADGroup -All $true
ForEach ($group in $groups){
$members = Get-AzureADGroupMember -ObjectId $group.ObjectId -All $true
ForEach ($member in $members){
Write-output $group.DisplayName "," $member.ObjectId "," $member.ObjectType $member.UserType "," $member.UserPrincipalName >> C:\scripts\output.csv
}
}
答案 1 :(得分:0)
谢谢。我对它进行了一些调整,以换成其他输出格式。
Connect-AzureAD
$groups=Get-AzureADGroup -All $true
$resultsarray =@()
ForEach ($group in $groups){
$members = Get-AzureADGroupMember -ObjectId $group.ObjectId -All $true
ForEach ($member in $members){
$UserObject = new-object PSObject
$UserObject | add-member -membertype NoteProperty -name "Group Name" -Value $group.DisplayName
$UserObject | add-member -membertype NoteProperty -name "Member Name" -Value $member.DisplayName
$UserObject | add-member -membertype NoteProperty -name "ObjType" -Value $member.ObjectType
$UserObject | add-member -membertype NoteProperty -name "UserType" -Value $member.UserType
$UserObject | add-member -membertype NoteProperty -name "UserPrinicpalName" -Value $member.UserPrincipalName
$resultsarray += $UserObject
}
}
$resultsarray | Export-Csv -Encoding UTF8 -Delimiter ";" -Path "C:\scripts\output.csv" -NoTypeInformation