Microsoft 365 groups are built for collaboration. When you create a Microsoft 365 group multiple items are created to facilitate this collaboration, this includes;
- Exchange Mailbox & Calendar
- SharePoint Team Site & OneNote notebook
- Stream
- Planner
- Power BI Workspace
With this in mind, it is not just the administrator of your tenant that can create Microsoft 365 groups. When users create a Team in Microsoft Teams, a corresponding Microsoft 365 group is created, which includes all of the above features. So at a glace, it can be hard for an administrator or compliance member to track Microsoft 365 groups and memberships manually.
Also, Microsoft 365 groups can have dynamic group memberships, so with a complex group membership structure, it may be easier for you to view the group memberships to confirm a user has been added correctly.
In this post, I am going to show you how to export a list of all Microsoft 365 groups and the group members using PowerShell in your Microsoft 365 tenant.
How to Export all Microsoft 365 Groups and Members with PowerShell
- Install the Exchange Online PowerShell module
Install-Module ExchangeOnlineManagement - Use the Get-Module command to verify the ExchangeOnlineManagement module is installed
Get-Module
- Use the following script to export a list of all Microsoft 365 groups and their members to a CSV file
$Result=@()
$groups = Get-UnifiedGroup -ResultSize Unlimited
$totalmbx = $groups.Count
$i = 1
$groups | ForEach-Object {
Write-Progress -activity "Processing $_.DisplayName" -status "$i out of $totalmbx completed"
$group = $_
Get-UnifiedGroupLinks -Identity $group.id -LinkType Member | ForEach-Object {
$member = $_
$Result += New-Object PSObject -property @{
GroupName = $group.DisplayName
Member = $member.Name
EmailAddress = $member.PrimarySMTPAddress
RecipientType= $member.RecipientType
}}
$i++
}
$Result | Export-CSV "All-M365-Group-Members.csv" -NoTypeInformation -Encoding UTF8 - Your results should look like the following
To summarise, this script will loop through the members of each group and export them to a basic CSV file which can be manipulated after. To see a breakdown of my most used PowerShell commands for Exchange online, check out my post The most useful Exchange Online Powershell Commands you should know


Dont forget to add connect-exchangeonline
might be simple but I forgot and was banging head for ages, thanks for the useful script it works once I rememebered to connect 😀
Thanks for sharing your results with us. I copied the script, and it looked like it worked and showed a loading bar. The script stopped at the last line. I hit enter for that, but nothing happened. I don’t see a path for where the results will be saved, so I am assuming that I will open Excel once it’s ready?