The Get-MgGroupOwner cmdlet is part of the Microsoft Graph PowerShell module, designed to retrieve the owners of a specified Microsoft 365 group. Group owners have administrative privileges over the group, including managing memberships and settings.
Managing Microsoft 365 groups efficiently requires visibility into their ownership. Administrators can use Get-MgGroupOwner to:
Get-MgGroupOwner -GroupId [-All] [-Filter <String>] [-Search <String>]
Key Parameters:
Get-MgGroupOwner -GroupId "1e141d1d-71c0-4f24-8ed2-2ce3a63c28d5"
This command retrieves all owners of the specified group.
Get-MgGroupOwner
If no -GroupId parameter is provided, the console may prompt the user to enter a valid group ID interactively.
The following script retrieves detailed user information for each group owner:
# Retrieve owners of the specified group
$groupOwners = Get-MgGroupOwner -GroupId "1e141d1d-71c0-4f24-8ed2-2ce3a63c28d5"
# Initialize an array to store detailed user information
$userDetails = @()
# Loop through each group owner and retrieve additional properties
foreach ($member in $groupOwners) {
$user = Get-MgUser -UserId $member.Id -Property "id, displayName, userPrincipalName"
$userDetails += [PSCustomObject]@{
Id = $user.Id
DisplayName = $user.DisplayName
UserPrincipalName = $user.UserPrincipalName
}
}
# Display the detailed user information
$userDetails | Select-Object Id, DisplayName, UserPrincipalName
This script enhances the basic Get-MgGroupOwner output by pulling additional user properties using the Get-MgUser cmdlet.
Can I retrieve owners for multiple groups at once?
No, Get-MgGroupOwner works on a single group at a time. To retrieve multiple groups, loop through their IDs.
Does this cmdlet return only users, or does it include other objects?
It returns all owners, including users and service principals if they are assigned as group owners.
How can I check if a specific user is an owner of a group?
Use Get-MgGroupOwner with Where-Object to filter results based on user ID or email.
The Get-MgGroupOwner cmdlet is essential for managing Microsoft 365 groups effectively. By fetching group owners and their details, administrators can streamline group management, ensure compliance, and automate administrative tasks. Whether used for audits, troubleshooting, or automation, this cmdlet plays a crucial role in maintaining a well-managed Microsoft 365 environment.
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