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?

As an admin, you can get Office 365 groups through Microsoft 365 admin center.

  • Login to the Microsoft 365 Admin Center site:
  • Expand “Groups” and Click on “Groups” in the left navigation. 
  • In the “View” drop-down, Select “Office 365”. That list’s all Office 365 groups to the page.
    How to Get Office 365 Groups

Get Office 365 Group Details using PowerShell

Use Get-UnifiedGroup cmdlet to get all Office 365 groups in Office 365.

#Get Credentials to connect
$Credential = Get-Credential
#Create the session
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri `
           -Credential $Credential -Authentication Basic -AllowRedirection
#Import the session
Import-PSSession $Session -DisableNameChecking

#Get all Office 365 Group

#Remove the session 
Remove-PSSession $Session

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 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

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

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply