Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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

3 REPLIES 3
AnonymousPerson
Advocate V
Advocate V

Cool!  How do I use Powershell as a source in Power Query though?

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.