Migrating from Add-AzureADGroupOwner to New-MgGroupOwnerByRef

With Microsoft retiring the AzureAD module, it's time for administrators to adopt the Microsoft Graph PowerShell SDK for group management tasks. One such cmdlet, Add-AzureADGroupOwner, was commonly used to assign owners to Microsoft 365 groups. Its modern Graph counterpart is New-MgGroupOwnerByRef.

In this article, we’ll walk through how to migrate your scripts to use New-MgGroupOwnerByRef, cover what’s different, and provide usage examples for single and bulk owner assignments.


What You Did Previously with Add-AzureADGroupOwner?

The Add-AzureADGroupOwner cmdlet allowed you to assign users as group owners using their ObjectId and the group’s ObjectId.

Example

Add-AzureADGroupOwner -ObjectId "your-group-id" -RefObjectId "new-owner-id"

While this was a simple approach, it was tied to the legacy AzureAD module, which is now deprecated and no longer receives updates.


What You Should Do Now with New-MgGroupOwnerByRef?

The Microsoft Graph PowerShell SDK introduces New-MgGroupOwnerByRef, which performs the same task but requires the new Graph-compliant format using an @odata.id reference.


Example 1: Add a Single Owner to a Group

$groupId = "your-group-id"
$ownerId = "new-owner-id"
                                            
$body = @{
    "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/$ownerId"
}
                                            
New-MgGroupOwnerByRef -GroupId $groupId -BodyParameter $body
                                        

Example 2: Add Multiple Owners to a Group

$groupId = "your-group-id"
$ownerIds = @("owner-id-1", "owner-id-2", "owner-id-3")
                                            
foreach ($ownerId in $ownerIds) {
    $body = @{
        "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/$ownerId"
    }
    New-MgGroupOwnerByRef -GroupId $groupId -BodyParameter $body
}
                                        

This method is scalable and ideal for adding multiple owners programmatically based on a list, CSV import, or HR system feed.


What’s Different with New-MgGroupOwnerByRef?


🔄 Old (Add-AzureADGroupOwner) ➡️ New (New-MgGroupOwnerByRef)
-ObjectId, -RefObjectId -GroupId, -BodyParameter
Direct ID input Requires full @odata.id Graph URL
AzureAD module (deprecated) Microsoft.Graph.Groups module
Not aligned with Graph API Fully compliant with Microsoft Graph architecture
Limited scalability Ideal for automation and bulk scenarios

Conclusion

Migrating from Add-AzureADGroupOwner to New-MgGroupOwnerByRef is a necessary step to modernize your Microsoft 365 group management scripts. While the newer syntax requires referencing the Graph API using @odata.id, the shift unlocks greater flexibility, automation capabilities, and alignment with Microsoft’s secure, API-first future.

Whether you're assigning a single owner or updating multiple group owner roles, New-MgGroupOwnerByRef ensures your scripts are Graph-ready and future-proof.

Visit M365Corner.com for ready-to-use free Microsoft Graph PowerShell tools and step-by-step migration guides built for Microsoft 365 administrators.



Permission Required

Example:


                                


                                


                                

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