Direct Inward Dialing: +1 408 916 9393
This guide covers how to generate the membership list of Microsoft 365 groups using the Microsoft 365 admin center, PowerShell, or ManageEngine ADManager Plus. It also explores scheduling and exporting the membership lists.
These tab names apply to Microsoft 365 groups. Distribution lists and security groups open with a Members tab and a View all and manage members link instead.
To install both modules, run:
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser
Install-Module Microsoft.Graph -Scope CurrentUser
Exchange Online PowerShell reads membership with Get-UnifiedGroupLinks, and Microsoft Graph PowerShell reads it with Get-MgGroupMember. Both return the direct members of a Microsoft 365 group.
Connect-ExchangeOnline -UserPrincipalName admin@zylker.com
Get-UnifiedGroup -ResultSize Unlimited | Select-Object DisplayName, Alias, PrimarySmtpAddress
Get-UnifiedGroupLinks -Identity "marketing@zylker.com" -LinkType Members -ResultSize Unlimited | Select-Object DisplayName, PrimarySmtpAddress
Get-UnifiedGroupLinks -Identity "marketing@zylker.com" -LinkType Members -ResultSize Unlimited | Select-Object DisplayName, PrimarySmtpAddress | Export-Csv -Path "C:\Reports\Marketing-members.csv" -NoTypeInformation
Disconnect-ExchangeOnline -Confirm:$false
Connect-MgGraph -Scopes "GroupMember.Read.All","User.Read.All"
Get-MgGroup -Filter "DisplayName eq 'Marketing'" | Select-Object Id, DisplayName
Get-MgGroupMember -GroupId "<group-id>" -All | Select-Object Id, @{Name="DisplayName";Expression={$_.AdditionalProperties["displayName"]}}, @{Name="Mail";Expression={$_.AdditionalProperties["mail"]}}
Get-MgGroupMember -GroupId "<group-id>" -All | Select-Object Id, @{Name="DisplayName";Expression={$_.AdditionalProperties["displayName"]}}, @{Name="Mail";Expression={$_.AdditionalProperties["mail"]}} | Export-Csv -Path "C:\Reports\Marketing-members-graph.csv" -NoTypeInformation
Disconnect-MgGraph
The following parameters are used when listing Microsoft 365 groups in Exchange Online.
| Parameter | Description |
|---|---|
| -Identity | The group to return. Accepts the name, alias, distinguished name, canonical DN, email address, or GUID. |
| -Filter | Returns only the groups that match an OPATH filter, such as ResourceProvisioningOptions -eq "Team". |
| -ResultSize | The maximum number of groups to return. The default is 1,000. Use Unlimited to return all. |
| -SortBy | Sorts the results by Name, DisplayName, or Alias. |
| -IncludeSoftDeletedGroups | Includes deleted groups that can still be recovered. |
The following parameters are used when reading the members of a Microsoft 365 group.
| Parameter | Description |
|---|---|
| -Identity | The group to read. Accepts the same values as Get-UnifiedGroup and takes pipeline input from it. |
| -LinkType | Required. Members, Owners, or Subscribers. |
| -ResultSize | The maximum number of results to return. The default is 1,000. Use Unlimited to return all. |
The following parameters are used when finding the Group ID in Microsoft Graph PowerShell.
| Parameter | Description |
|---|---|
| -Filter | Returns the groups that match a filter, such as "DisplayName eq 'Marketing'". |
| -GroupId | The Group ID of a single group to return. |
| -All | Returns all pages of results. |
| -Property | Selects the properties to return. |
The following parameters are used when listing group members in Microsoft Graph PowerShell.
| Parameter | Description |
|---|---|
| -GroupId | Required. The Group ID of the group whose members you want. |
| -All | Returns all pages of results. Graph returns 100 members per page by default. |
| -Filter | Filters the members by property values. Needs -ConsistencyLevel eventual and -CountVariable. |
| -PageSize | Sets the page size of the results. |
| -Property | Selects the properties to return. |
ADManager Plus is a tool for managing and reporting on AD, Microsoft 365, and Exchange, and group membership reports are one of its Microsoft 365 reports.
This script loops through every Microsoft 365 group, reads its members with Get-UnifiedGroupLinks, and writes one row per member to a single CSV file.
Connect-ExchangeOnline -UserPrincipalName admin@zylker.com
Get-UnifiedGroup -ResultSize Unlimited | ForEach-Object {
$group = $_
Get-UnifiedGroupLinks -Identity $group.Name -LinkType Members -ResultSize Unlimited | ForEach-Object {
[PSCustomObject]@{
Group = $group.DisplayName
Member = $_.DisplayName
EmailAddress = $_.PrimarySmtpAddress
RecipientType = $_.RecipientType
}
}
} | Export-Csv -Path "C:\Reports\All-M365-group-members.csv" -NoTypeInformation -Encoding UTF8
Disconnect-ExchangeOnline -Confirm:$false
To get the same list without a script, use the Group Members report in ADManager Plus:
Filter the member list for the user's email address. If the command returns nothing, the user is not a direct member. Use the address the member has in Exchange Online, which can differ from the sign-in name.
Get-UnifiedGroupLinks -Identity "marketing@zylker.com" -LinkType Members -ResultSize Unlimited | Where-Object { $_.PrimarySmtpAddress -eq "jsmith@zylker.com" }
In Microsoft Graph PowerShell, check whether the user's object ID appears in the Get-MgGroupMember results. In ADManager Plus, generate the Group Members report for the group and look for the user.
Get-UnifiedGroupLinks reads Microsoft 365 groups. Get-DistributionGroupMember reads distribution groups and mail-enabled security groups, so it does not return the members of a Microsoft 365 group. For distribution groups, see how to export distribution group members using PowerShell.
Run Get-UnifiedGroupLinks with -LinkType Owners instead of -LinkType Members. In Microsoft Graph PowerShell, Get-MgGroupOwner returns the owners, as explained in this guide to getting Entra ID group owners.
Graph returns each member as a directory object, so the display name and email address sit in AdditionalProperties instead of in columns. If those values are empty too, the session cannot read users. Reconnect with User.Read.All in the scopes. For the parameters of the cmdlet, see how to get Entra ID group members with Get-MgGroupMember.
No. You cannot add a distribution list or another Microsoft 365 group as a member of a Microsoft 365 group, so there is no nested group to expand when you list the members.
Yes. Microsoft Teams uses a Microsoft 365 group for its membership, so the same commands list a team's members. To list only the groups that back a team, run:
Get-UnifiedGroup -Filter {ResourceProvisioningOptions -eq "Team"}
The execution policy is blocking the module scripts. Run Set-ExecutionPolicy RemoteSigned in an elevated PowerShell session, then connect again.
The ExchangeOnlineManagement module is not installed or not loaded. Run Install-Module -Name ExchangeOnlineManagement, then Import-Module ExchangeOnlineManagement, and connect again.
Connections to Exchange Online on Windows need the PowerShellGet module, which in turn needs PackageManagement. Install or update both, close and reopen PowerShell, and connect again.
The account may lack an Exchange Online role that includes these cmdlets, such as View-Only Recipients, or the connection may not have completed. Check the role assignment, then disconnect and connect again.
Get-UnifiedGroup and Get-UnifiedGroupLinks return 1,000 results by default. Add -ResultSize Unlimited to both commands.
The -Identity value was $null or does not match any group, and Exchange Online then returns all groups. This often happens inside a loop. Check that the value exists before you pass it.
Graph returns 100 members per page by default. Add -All to return every page.
Exchange Online cmdlets that use the REST API time out after 15 minutes. Run the loop for fewer groups at a time, for example by narrowing Get-UnifiedGroup with -Filter.