简体   繁体   中英

List members from nested Azure AD group

I have an Azure AD Group, "All-Team". That inturn has three groups:

  1. SrMgr_E3
  2. directs
  3. Sachbearbeiter

Each group has a list of members and I want to fetch members from the groups.

The below command gives me list of groups, but I want it to give a list of members from all the group. I was assuming that Azure AD was a FLAT structure and it would list out all the members from the group (nested including).

$group_objectid = (Get-AzureADGroup -SearchString 'All-Team').objectid
Get-AzureADGroupMember -ObjectId $group_objectid

The above command will give me list of three groups, but I want the list of all the members from that group. Is there a command that does that?

There is no such command, the list members operation is not transitive, your option is to use a loop:

$group_objectid = (Get-AzureADGroup -SearchString 'joytestg').ObjectId
$group2_objectid = (Get-AzureADGroupMember -ObjectId $group_objectid).ObjectId
foreach($item in $group2_objectid){
    Get-AzureADGroupMember -ObjectId $item
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM