Managing Microsoft 365 Groups includes not just assigning the right owners but also removing outdated or incorrect ownership assignments. Whether an employee has changed roles or left the organization, it's essential to keep group ownership updated to avoid administrative gaps.
The Remove-MgGroupOwnerByRef cmdlet in Microsoft Graph PowerShell makes this task seamless. In this guide, you'll learn what it does, when to use it, and how to remove group owners—individually or in bulk.
Remove-MgGroupOwnerByRef is a Microsoft Graph PowerShell cmdlet that lets you remove an owner from a Microsoft 365 Group by referencing their directory object ID. This approach is part of the modern Graph API model, which uses RESTful references to modify group associations.
Using this cmdlet ensures:
It’s especially useful in automation scripts, compliance routines, and role-based cleanups.
Remove-MgGroupOwnerByRef -GroupId <String> -DirectoryObjectId <String> [-Confirm]
Remove-MgGroupOwnerByRef -GroupId "12345678-9abc-def0-1234-56789abcdef0" `-DirectoryObjectId "87654321-fedc-ba98-7654-3210fedcba98"
This command removes the specified user as an owner from the group.
$GroupId = "12345678-9abc-def0-1234-56789abcdef0"
$Owners = @(
"87654321-fedc-ba98-7654-3210fedcba98",
"01234567-89ab-cdef-0123-456789abcdef"
)
foreach ($Owner in $Owners) {
Remove-MgGroupOwnerByRef -GroupId $GroupId -DirectoryObjectId $Owner
}
Great for removing multiple users during access reviews or team transitions.
CSV Format
Ensure your CSV file (e.g., owners.csv) looks like this:
DirectoryObjectId
87654321-fedc-ba98-7654-3210fedcba98
01234567-89ab-cdef-0123-456789abcdef
PowerShell Script
$GroupId = "12345678-9abc-def0-1234-56789abcdef0"
$CsvData = Import-Csv -Path "C:\path\to\owners.csv"
foreach ($Owner in $CsvData) {
Remove-MgGroupOwnerByRef -GroupId $GroupId -DirectoryObjectId $Owner.DirectoryObjectId
}
This is ideal for bulk de-provisioning and scheduled cleanups.
Use the following command: Get-MgUser -UserId "username@domain.com" | Select-Object Id
Yes. Every group should ideally have at least one owner. If the last owner is removed, no one can manage the group unless reassigned.
No. The cmdlet requires the user's Directory Object ID (GUID), not email or UPN.
Run: Get-MgGroupOwner -GroupId
The Remove-MgGroupOwnerByRef cmdlet is a simple yet powerful tool for maintaining accurate ownership of Microsoft 365 Groups. With support for single, multiple, and CSV-based bulk operations, it offers flexibility and control to IT administrators managing group governance at scale.
If you’re running cleanup routines or building automated scripts for group management, this cmdlet should be a key part of your toolkit.
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