Managing Microsoft 365 Groups efficiently means ensuring the right people have the right permissions—and assigning owners is a critical part of that process. Whether you're managing a single group or automating assignments across your organization, the New-MgGroupOwnerByRef cmdlet from Microsoft Graph PowerShell simplifies adding group owners using their unique identifiers.
In this blog, we’ll explore what this cmdlet does, why you should use it, and walk through practical examples—including how to add owners in bulk using a CSV file.
The New-MgGroupOwnerByRef cmdlet is part of the Microsoft Graph PowerShell SDK. It allows administrators to assign one or more users as owners of an existing Microsoft 365 Group by referencing the user’s object via the Microsoft Graph API.
Unlike traditional methods that require modifying the group object directly, this cmdlet works by creating a reference (via @odata.id) to the user you wish to add.
Assigning ownership through this method offers several benefits:
New-MgGroupOwnerByRef -GroupId <String> -BodyParameter <Hashtable>
$Owner = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/users/{UserId}"
}
New-MgGroupOwnerByRef -GroupId "5c67f5b3-b1c4-4c16-842d-11b453b6f270" -BodyParameter $Owner
Replace {UserId} with the actual Azure AD object ID of the user you want to assign as an owner.
$Owners = @(
@{
"@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/2017e571-90fd-4671-96bb-360c678f4d23"
}
@{
"@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/55bafc67-7ba0-4964-840a-53d480542ab8"
}
)
foreach ($Owner in $Owners) {
New-MgGroupOwnerByRef -GroupId "3a408d7b-d2d1-4ec6-812f-b9ad64187a13" -BodyParameter $Owner
}
This loop ensures that each directory object is added individually to the specified group.
Assume your CSV file Owners.csv contains a header UserId with user GUIDs:
UserId
2017e571-90fd-4671-96bb-360c678f4d23
55bafc67-7ba0-4964-840a-53d480542ab8
Now use the following script:
$OwnersFromCSV = Import-Csv -Path "C:\Path\To\Owners.csv"
foreach ($Owner in $OwnersFromCSV) {
$OwnerHash = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/users/$($Owner.UserId)"
}
New-MgGroupOwnerByRef -GroupId "5c67f5b3-b1c4-4c16-842d-11b453b6f270" -BodyParameter $OwnerHash
}
This is a quick way to add multiple owners without hardcoding each ID.
No. You must use the user’s Object ID or Directory Object ID. Use Get-MgUser to retrieve it.
No. It adds new owners without affecting existing ones.
No. Only users or directory objects can be group owners.
Use: Get-MgGroupOwner -GroupId
The New-MgGroupOwnerByRef cmdlet is a powerful and flexible way to manage Microsoft 365 Group ownership. By referencing users directly through their unique identifiers, you gain precision and automation capabilities ideal for modern IT environments.
Whether you're adding one owner or hundreds, this cmdlet keeps your group governance efficient and consistent.
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex