cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ccopca
Regular Visitor

Power BI - Can't get Azure AD Members (from a group)

Hello All,

I need to get all member (and all fields from that table) from two groups from Azure AD. I have tried different ways, so far no luck.

I used OData Feed and Graph as below, and both lines just retrieve the id (member Id)

https://graph.microsoft.com/v1.0/groups/{my group Id}/members?$count=true

or

https://graph.microsoft.com/v1.0/groups/{my group Id}/members?$select=id,deviceId,displayName

I'm new in power bi and I will need to do more reports getting data from Intune and Azure AD. 

What it would be the right way to get these data?

Thanks

cc

2 REPLIES 2
ccopca
Regular Visitor

Thank s for your response Jianbo Li. This is going to be my first Power BI report and I'm kind of lost.

The reports will show certain devices data from Intune that are assigned to two groups (Azure AD groups I supposed, because I can't find any group in Intune). From Power BI, I can get the devices data from Intune Data Warehouse.

Can  you explain me how to use the Get-AzureADGroupMember cmdlet in PowerShell to retrieve the data from Power BI.

 

Many thanks,

cc 

v-jianboli-msft
Community Support
Community Support

Hi @ccopca ,

 

you can use the Get-AzureADGroupMember cmdlet in PowerShell to get all members and all fields from a group in Azure AD . You can specify the -ObjectId parameter with the ID of the group you want to query, and use the -All parameter to return all group members and fields. For example:

Get-AzureADGroupMember -ObjectId "group1-id" -All $true
Get-AzureADGroupMember -ObjectId "group2-id" -All $true

If you want to get all members and fields of nested groups, you can use a custom function in PowerShell that recursively queries the subgroups and returns all users and fields. For example:

Function Get-AzureADGroupMembers($groupId) {
  $output = @()
  $group = (Get-AzureADGroupMember -ObjectId $groupId -All $True| Select ObjectId).ObjectId
  foreach($objectid in $group) {
    $aad_object = Get-AzureADObjectByObjectId -ObjectId $objectid
    #Add to output if object is a user or a device
    if ($aad_object.ObjectType -eq 'User' -or $aad_object.ObjectType -eq 'Device') {
      $output += New-Object PSObject -Property @{ 
        Name = $aad_object.DisplayName
        UserPrincipalName = $aad_object.UserPrincipalName
        ObjectId = $aad_object.ObjectId
        ObjectType = $aad_object.ObjectType
      }
    }
    #Recursively call function if object is a group
    if ($aad_object.ObjectType -eq 'Group') {
      $output += Get-AzureADGroupMembers -groupId $objectid
    }
  }
  return $output
}

#Call function for each group you want to query
Get-AzureADGroupMembers -groupId "group1-id"
Get-AzureADGroupMembers -groupId "group2-id"

Refer to:

azure - Powershell : Get-AzureADGroupMember get all memebers of nested groups - Stack Overflow

Get-AzureADGroupMember (AzureAD) | Microsoft Learn 

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors