How to Find All Office 365 Groups using PowerShell?

Requirement: Get Office 365 Groups using PowerShell.

How to Get Office 365 Groups in Admin Center?

Microsoft Office 365 Groups provide a simple and efficient way to collaborate with others in your organization. However, manually locating all the groups in your tenant can be a tedious task. This blog post will show you how to use PowerShell to quickly find all Office 365 groups in your tenant.

The Microsoft 365 admin center provides a user-friendly interface for managing your Office 365 environment. You can get Office 365 groups through Microsoft 365 admin center as an admin. Follow these steps:

  1. Log in to the Microsoft 365 Admin Center site:
  2. Expand “Teams & Groups” and click on “Active teams & groups” in the left navigation. 
  3. On the Groups page, select the “Office 365” tab. That list’s all Office 365 groups on the page.
    get list of office 365 groups powershell

You can export these groups to Excel using the “Export” button in the command bar.

Get Office 365 Group Details using PowerShell

To get a list of all Office 365 groups in your organization, you can use PowerShell. Use the Get-UnifiedGroup cmdlet to get all Office 365 groups in Office 365.

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

#Get all Office 365 Group

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

This cmdlet retrieves all Office 365 groups.

get office 365 group using powershell

You may query specific properties of the Office 365 group by,

Get-UnifiedGroup | Format-Table Alias, WhenCreated, WhenChanged, SharePointSiteUrl

Similarly, to get an Office 365 group ID using PowerShell, use:

Get-UnifiedGroup -Identity "Marketing" | Select ID

Export Office 365 Groups using PowerShell

Get-UnifiedGroup | Select Guid,DisplayName,Alias, AccessType,ManagedBy,WhenCreated | Export-Csv -Path "C:\Temp\Groups.csv" -NoTypeInformation

This PowerShell generates a CSV file as:

Export Office 365 groups to CSV using powershell

PnP PowerShell to Get All Microsoft 365 Groups

The below PnP PowerShell script gets all Microsoft 365 groups in your tenant and exports groups data to a CSV file:

  • Group Name
  • Group ID
  • Has Microsoft Team
  • Visibility (Private or Public)
  • Group Mail
  • Created Date & Time
  • Group Owners
  • Group Members
#Config Variables
$AdminSiteURL = ""
$CSVPath = "C:\Temp\GroupsData.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 & Members of the group
        $GroupOwners = (Get-PnPMicrosoft365GroupOwners -Identity $Group | Select -ExpandProperty UserPrincipalName) -join ";"
        $GroupMembers = (Get-PnPMicrosoft365GroupMembers -Identity $Group  | Select -ExpandProperty UserPrincipalName) -join ";"

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

PowerShell to get all Office 365 Groups from Azure AD

We can also get a list of Office 365 groups using Azure AD PowerShell cmdlets.

#Connect to Azure AD

#Get All Microsoft 365 groups
Get-AzureADMSGroup -Filter "groupTypes/any(c:c eq 'Unified')" -All:$true

To get all owners of Office 365 groups, use: Find All Office 365 Group Owners using PowerShell

In summary, by following these simple steps, you can quickly get a list of all Office 365 groups in your organization using the Microsoft 365 admin center or PowerShell. This can be useful for various purposes, such as auditing, reporting, or management.

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 *