Migrating from Get-AzureADGroupMember to Get-MgGroupMember

As Microsoft retires the AzureAD module, it's time to move your group membership management scripts over to the modern Microsoft Graph PowerShell SDK. One of the most widely used AzureAD cmdlets was Get-AzureADGroupMember, which helped administrators retrieve members of a Microsoft 365 group.

In this guide, we’ll walk you through how to migrate to the Graph equivalent — Get-MgGroupMember — highlight the key differences, and provide practical examples you can start using today.


What You Did Previously with Get-AzureADGroupMember

The Get-AzureADGroupMember cmdlet was commonly used to retrieve the list of members for a given Azure AD group.

Example

Get-AzureADGroupMember -ObjectId "1cbe8c31-589d-453a-a1e5-045f7f00c967"

This would return all the members (users, devices, or service principals) associated with the group ID provided.

While this worked well, AzureAD module cmdlets are now deprecated and no longer receiving feature updates or security improvements.


What You Should Do Now with Get-MgGroupMember

In the Microsoft Graph PowerShell SDK, the cmdlet you’ll use is Get-MgGroupMember.


Retrieve Group Member IDs

Get-MgGroupMember -GroupId "1cbe8c31-589d-453a-a1e5-045f7f00c967"

This retrieves a list of member objects associated with the specified group. It outputs the IDs and basic details of the members.


Retrieve Group Members with Personal Info

To fetch detailed information such as Display Name and UserPrincipalName for each group member, you can combine it with Get-MgUser:

# Retrieve members of a specified group
$groupMembers = Get-MgGroupMember -GroupId "1cbe8c31-589d-453a-a1e5-045f7f00c967"
                                                                                            
# Initialize an array to store detailed user information
$userDetails = @()                                          
# Loop through each group member and retrieve additional properties
foreach ($member in $groupMembers) {
    $user = Get-MgUser -UserId $member.Id -Property "id, displayName, userPrincipalName"
    $userDetails += [PSCustomObject]@{
        Id                 = $user.Id
        DisplayName        = $user.DisplayName
        UserPrincipalName  = $user.UserPrincipalName
    }
}
                                                                                            
# Display the detailed user information
$userDetails | Select-Object Id, DisplayName, UserPrincipalName
                                        

This approach is great for reporting, exporting group membership lists, or auditing users.


What’s Different with Get-MgGroupMember?


🔄 Old (Get-AzureADGroupMember) ➡️ New (Get-MgGroupMember)
Parameter: -ObjectId Parameter: -GroupId (accepts GUID)
Part of AzureAD module (deprecated) Part of Microsoft.Graph.Groups module
Basic member list returned Supports richer property selection with Graph
No easy expansion to detailed info Combine with Get-MgUser for extended info
AzureAD API backend Microsoft Graph API backend (broader, faster)

Conclusion

Migrating from Get-AzureADGroupMember to Get-MgGroupMember ensures your scripts are future-proof, secure, and compatible with all Microsoft 365 services.
The transition is straightforward, and by leveraging Graph’s flexibility, you can generate richer reports and more detailed group audits with minimal effort.

Start using Get-MgGroupMember today to modernize your Microsoft 365 administration workflows!



Permission Required

Example:


                                


                                


                                

© Your Site Name. All Rights Reserved. Design by HTML Codex