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.
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.
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.
$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
$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.
🔄 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 |
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.
© Your Site Name. All Rights Reserved. Design by HTML Codex