With the deprecation of the AzureAD module, Microsoft encourages all administrators to transition to Microsoft Graph PowerShell. This article focuses on migrating from the Get-AzureADGroupOwner cmdlet to the Graph equivalent: Get-MgGroupOwner.
Using the AzureAD module, you could retrieve the owners of a Microsoft 365 group using a simple cmdlet:
Get-AzureADGroupOwner -ObjectId "7bf57d88-42e1-4c8b-8a44-5a6f04a29073"
This command returned basic owner details, allowing you to further manipulate or export them.
The equivalent Graph PowerShell cmdlet is Get-MgGroupOwner, and it provides a more modern, REST-compliant way to retrieve group owners. To use this cmdlet, you must first connect to Microsoft Graph:
Connect-MgGraph -Scopes "Group.Read.All"
Then, use the following syntax:
Get-MgGroupOwner -GroupId "your-group-id"
Retrieve only the owner IDs of a Microsoft 365 Group:
Get-MgGroupOwner -GroupId '7bf57d88-42e1-4c8b-8a44-5a6f04a29073' | Select-Object Id
Retrieve the detailed information (display name, email, UPN) of each group owner:
$owners = Get-MgGroupOwner -GroupId '7bf57d88-42e1-4c8b-8a44-5a6f04a29073'
foreach ($owner in $owners) {
Get-MgUser -UserId $owner.Id | Select-Object DisplayName, Mail, UserPrincipalName
}
This approach is ideal when you're building reports or conducting audits on group ownership.
Feature | AzureAD Cmdlet | Graph PowerShell Cmdlet |
Module | AzureAD | Microsoft.Graph |
Syntax | -ObjectId | -GroupId |
Output Format | Default user object | Directory object (often requires casting or additional query) |
Data Enrichment | Native properties | Requires Get-MgUser for full details |
Authentication | Connect-AzureAD | Connect-MgGraph -Scopes "Group.Read.All" |
✅ Pro Tip: Use Select-Object or pipe Get-MgUser to get complete profile details when using Graph.
Migrating to Get-MgGroupOwner is a necessary step as AzureAD cmdlets are being phased out. While the basic functionality remains the same, Graph PowerShell adds more flexibility, scalability, and alignment with Microsoft’s future roadmap. Start updating your scripts now to ensure long-term compatibility and improved functionality.
© Your Site Name. All Rights Reserved. Design by HTML Codex