Forum Discussion
Microsoft Graph API - Get members from cloud only groups
$Groups = Get-AzureADGroup -All $true | Where-Object {$_.GroupType -eq "Unified"}
$Results = @()
foreach ($Group in $Groups) {
if ($Group.SecurityEnabled -eq $false) {
$Members = Get-AzureADGroupMember -ObjectId $Group.ObjectId
$Results += $Members | Select-Object @{Name="GroupName"; Expression={$Group.DisplayName}}, DisplayName, UserPrincipalName
}
}
$Results | Export-Csv -Path "CloudOnlyGroupsMembers.csv" -NoTypeInformation
Thanks for the script.
The thing is that i'm really searching on how to establish this with an ODATA query in Microsoft Graph Explorer.
Any idea on that part?
With kind regards,
Sebastian Mellebeek
- Mar 14, 2023
Sebastian Mellebeek try this and let me know if it works
Go to the Microsoft Graph Explorer website: https://developer.microsoft.com/en-us/graph/graph-explorer
Sign in with your Microsoft account.
Select the "v1.0" version of the Microsoft Graph API.
In the query box, enter the following URL:
This will retrieve all groups in your organization that are cloud-only (i.e., have the "Unified" group type).
Click the "Run query" button.
If there are many groups, you may need to use the $top query parameter to limit the number of results returned. For example, you can add ?$top=50 to the end of the URL to return only the first 50 groups.
For each group returned in the response, you can retrieve the members by adding /members to the end of the group's ID in the id field. For example:
Replace {group-id} with the ID of the group for which you want to retrieve the members.
If a group has many members, you may need to use the $top query parameter to limit the number of results returned. For example, you can add ?$top=50 to the end of the URL to return only the first 50 members.
If a group has more members than the $top parameter specified, you can use the $skip query parameter to retrieve the next page of results. For example, you can add ?$top=50&$skip=50 to the end of the URL to retrieve the second page of results.
- Sebastian MellebeekMar 14, 2023Copper Contributor
Hey elieelkarkafi,
Thanks again for helping.
As of step 7, this is a new query, right? Or can we combine the query from step 4 and step 7 into one query? Because in the end, that would be the outcome that I need.
With kind regards,
Sebastian Mellebeek