Find All Office 365 Group Owners using PowerShell

Requirement: Get Office 365 Group Owners.

How to Get Office 365 Group Owners?

Office 365 groups are a powerful tool for collaboration and information sharing within an organization. As an administrator, you may need to view the owner of a group to manage its access and permissions. If you need to get a list of Office 365 Group owners in your organization, this guide is for you! This blog post will show you how to use PowerShell to find all group owners in Office 365. Let’s get started!

To get Office 365 group owners from Microsoft 365 admin center, do the following:

  1. Log in to the Microsoft 365 Admin Center site: https://admin.microsoft.com
  2. Expand “Teams & Groups” and Click on “Active Teams & Groups” in the left navigation.
  3. The group’s page lists all groups in your Office 365 tenant. Pick the desired group to list the owners of the group.
  4. Click on the “Members” tab, and then click on “Owners”. This lists all Owners of the group.
    get office 365 group group owners using powershell

You can also use the Exchange Admin Center to get owners of a Microsoft 365 group.

  1. Sign in to the Exchange admin center using your admin credentials.
  2. In the Exchange admin center, navigate to the groups section.
  3. Find the group that you want to view the owner of and click on it.
  4. In the group’s details page, scroll down to the Owners section. Here you will see a list of all the group’s owners and their email addresses.

Keep in mind that you need the Global Admin and Exchange Administrator permission to access the Microsoft 365 admin center and Exchange admin center.

Get Office 365 Group Owners using PowerShell

You can use the Get-UnifiedGroup and Get-UnifiedGroupLinks cmdlets to get the owner of an Office 365 group using PowerShell. Supply the group’s email address or its distinguished name as input. Here’s an example of how you can use the cmdlet to get the owner of a group:

This script connects to Exchange Online and gets group owners of a given Office 365 group “[email protected]”.

#Connect to Exchange Online
Connect-ExchangeOnline -Credential (Get-Credential) -ShowBanner:$False

#Get Owners of a Office 365 Group
Get-UnifiedGroup -Identity "[email protected]" | Get-UnifiedGroupLinks -LinkType Owner | Select DisplayName, PrimarySmtpAddress

#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False

Find All Office 365 Group Owners using PowerShell:

To get owners of all Office 365 groups and export to CSV, use:

#Connect to Exchange Online
Connect-ExchangeOnline -ShowBanner:$False

#Get All Office 365 Groups
$GroupData = @()
$Groups = Get-UnifiedGroup -ResultSize Unlimited -SortBy Name

#Loop through each Group
$Groups | Foreach-Object {
    #Get Group Owners
    $GroupOwners = Get-UnifiedGroupLinks -LinkType Owners -Identity $_.Id | Select DisplayName, PrimarySmtpAddress
    $GroupData += New-Object -TypeName PSObject -Property @{
            GroupName = $_.Alias
            GroupEmail = $_.PrimarySmtpAddress 
            OwnerName = $GroupOwners.DisplayName -join "; "
            OwnerIDs = $GroupOwners.PrimarySmtpAddress -join "; "
    }
}
#Get Groups Data
$GroupData
$GroupData | Export-Csv "C:\Temp\GroupOwners.csv" -NoTypeInformation

#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False

PnP PowerShell to Get All Microsoft 365 Group Owners

Here is the PnP PowerShell script to get all owners from all groups in your Microsoft 356 environment.

#Config Variables
$AdminSiteURL = "https://crescent-admin.sharepoint.com"
$CSVPath = "C:\Temp\GroupsOwnersData.csv"

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $AdminSiteURL -Interactive

    #Get all Office 365 Groups
    $Groups = Get-PnPMicrosoft365Group
    
    $GroupsData = @()
    #Loop through each group
    ForEach($Group in $Groups)
    {
        Write-host "Processing Group:"$Group.DisplayName
        #Get Owners of the group
        $GroupOwners = (Get-PnPMicrosoft365GroupOwners -Identity $Group | Select -ExpandProperty UserPrincipalName) -join ";"

        #Get Group details
        $GroupsData += New-Object PSObject -property $([ordered]@{ 
            GroupName  = $Group.DisplayName
            Id = $Group.ID
            Visibility = $Group.Visibility
            Mail = $Group.Mail
            GroupOwners= $GroupOwners
        })
    }
    $GroupsData
    #Export Groups information to CSV
    $GroupsData | Export-Csv -Path $CSVPath -NoTypeInformation
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

Find Owners of an Office 365 Group using Azure AD PowerShell:

Make sure you have the “Azure AD” PowerShell Module installed before running this script!

#Connect to AzureAD
Connect-AzureAD -Credential (Get-Credential) | Out-Null

#Get Group Owners
Get-AzureADGroupOwner -ObjectId (Get-AzureADGroup -SearchString "Purchase").ObjectId

PowerShell to Generate Group Owners Report from Azure AD

#Get Credentials to connect
$Cred = Get-Credential
 
#Connect to AzureAD
Connect-AzureAD -Credential $Cred | Out-Null
$GroupData = @()

#Get all Office 365 Groups
Get-AzureADMSGroup -Filter "groupTypes/any(c:c eq 'Unified')" -All:$true | ForEach-object {
    $GroupName = $_.DisplayName
    
    #Get Owners
    $GroupOwners = Get-AzureADGroupOwner -ObjectId $_.ID | Select UserPrincipalName, DisplayName 

        $GroupData += New-Object PSObject -Property ([Ordered]@{ 
        GroupName = $GroupName
        OwnerID = $GroupOwners.UserPrincipalName -join "; "
        OwnerName = $GroupOwners.DisplayName -join "; "
    })
}

#Export Group Owners data to CSV
$GroupData
$GroupData | Export-Csv "C:\Temp\GroupOwners.csv" -NoTypeInformation

Script Output:

Office 365 Group Owners report

Conclusion:

In conclusion, getting the owners of an Office 365 group from a Microsoft 365 tenant is a simple and straightforward process. By following the steps outlined in this article, you can easily view the owner of a group and manage its access and permissions. The Microsoft 365 admin center and Exchange admin center provide an easy-to-use interface for managing Office 365 groups, and you can view the owner of a group quickly and easily with PowerShell cmdlets. Remember to have the necessary permission to access the center. These methods are useful for checking group ownership information and managing group access.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *