As an admin, monitoring groups and their membership is one of the routine tasks. Most admins prefer PowerShell over Microsoft admin center for better customization. So, let’s see how to get Microsoft 365 group report using PowerShell in this blog.
Get All Groups in Microsoft 365 using PowerShell
PowerShell offers multiple cmdlets like Get-MSolGroup, Get-AzureADGroup, Get-UnifiedGroup, Get-DistributionGroup, and Get-MgGroup to fetch group details—but picking the right one can be confusing. No worries! We’ve created an All-in-One PowerShell script that effortlessly exports group details and membership information to a CSV file in one go.
With the single script, you can generate multiple group reports with the help of advanced filtering options. Here are a few example reports,
- All groups report
- All groups membership report
- Get details for a list of groups (CSV import)
- Get membership for a list of groups (CVS import)
- Microsoft 365 security group report
- Microsoft 365 security group membership report
- Distribution group report
- Distribution group membership report
- Mail enabled security group report
- Mail-enabled security group membership report
- Empty group report (Group without member report)
- Group size report
Download Script: M365GroupReport
Additional Highlights of the Script:
- The script uses Microsoft Graph PowerShell.
- The script can be executed with certificate-based authentication (CBA) too.
- Exports the report result to CSV.
- You can get members count based on Member Type such as User, Group, Contact, etc.
- The script is scheduler friendly.
- Above all, the script exports output to nicely formatted 2 CSV files. One with group information and another with detailed group membership information.
Microsoft 365 Group Report – Script Execution Steps:
Method 1: Execute the script with MFA or non-MFA account
1 |
./M365GroupReport.ps1 |
After the script execution, both output files will be available in the execution directory.
Method 2: Execute the PowerShell Script with Certificate
1 |
.\M365GroupReport.ps1 -TenantId <TenantId> -ClientId <ClientId> -CertificateThumbprint <Certthumbprint> |
To use certificate-based authentication (CBA), you must register app in Entra which helps you connect to MS Graph with certificate.
Microsoft 365 Group Report- Sample Output:
The Microsoft 365 Group report has the following columns: Group Name, Email Address, Group Type, Group Members Count, and Members Count by Type.
Microsoft 365 Group Membership Report – Sample Output:
The Microsoft 365 group membership report has the following columns: Group Name, Group Email Address, Member Name, Member Email, and Member Type. Group member type is helpful in identifying type of a member such as user, group, and contact.
More Use-cases of Microsoft 365 Group Report Script:
As earlier said, the script supports advanced filtering params to get the report as per your requirement.
1. Export all Microsoft 365 Groups and Membership
To export all the Microsoft 365 groups, execute the script as follows:
1 |
./M365GroupReport.ps1 |
The exported report contains all the group types such as Distribution lists, security groups, mail-enabled Security groups, and unified groups. By referring to this report, admin can add or remove user from the group. You can also check groups and their ownership to ensure the right owner and member are assigned to the right groups.
2. Get Members for a List of Groups:
You can use –GroupIDsFile param to get the report for specific group(s) from the input list called “GroupId.txt” and exports all membership into CSV.
To get group report and membership report for specific groups, pass an input file with a GUID of groups.
1 |
./M365GroupReport.ps1 -GroupIDsFile C:/GroupId.txt |
The GroupIDsFile must follow the format below: Group identity separated by new line without a header.
You can also export users’ direct group membership to ensure they are assigned to the correct groups. This helps in verifying permissions, access control, and compliance with organizational policies.
3. Group Size Report:
To find larger groups, you can execute the script with –MinGroupMembersCount param. The below format exports all groups that have more than 50 members.
1 |
./M365GroupReport.ps1 -MinGroupMembersCount 50 |
Note: If you want to determine group membership (I.e., members count) based on certain conditions, you can use dynamic group membership.
4. Microsoft 365 Security Group Report:
Security groups are used for granting access to Microsoft 365 resources. To export all the security groups and their members, you can run the script with –Security param.
1 |
./M365GroupReport.ps1 -Security |
By referring group membership report, you can view the users who has rights and access to SharePoint sites and CRM Online.
5. Distribution List Report:
Distribution lists are used for sending notifications to a group of people. To export distribution group and their membership, you can use –DistributionList param while executing the script.
1 |
./M365GroupReport.ps1 -DistributionList |
You can also check our dedicated script on the distribution group membership report for a more detailed DL report.
6. Mail-enabled Security Groups Report:
This type of group works as regular security along with the ability to send mail to its members. To get a list of all the mail-enabled security groups, execute the script with –MailEnabledSecurity param.
1 |
./M365GroupReport.ps1 -MailEnabledSecurity |
The script exports all mail-enabled security groups info and membership to the CSV file.
7. Get Empty Groups Report:
To get an empty group report (i.e., groups without members), execute the script with –IsEmpty param.
1 |
./M365GroupReport.ps1 -IsEmpty |
By referring to this report, you can delete unused/inactive groups in your tenant. Similarly, some groups may also contain disabled users. You can generate a report on groups with disabled users to identify and manage inactive members or owners effectively.
8. Schedule Group Report to Run Periodically:
As said earlier, this script is scheduler friendly. You can pass the credential as a parameter. So, it will not prompt for username and password during execution. You can also use CBA method to run the script unattended.
1 |
./M365GroupReport.ps1 -UserName admin@contoso.com -Password XXX |
You can use Windows Task Scheduler to run the script as scheduled task.
9. Get more Granular Group Report:
To export a more granular group report, you can use multiple filters (i.e., params and switches). I have given few examples below.
- To get empty distribution groups,
1 |
./M365GroupReport.ps1 -IsEmpty -DistributionList |
- To view empty security groups,
1 |
./M365GroupReport.ps1 -IsEmpty -Security |
- To list empty mail-enabled security groups,
1 |
./M365GroupReport.ps1 -IsEmpty -MailenabledSecurity |
- To get large distribution groups,
1 |
./M365GroupReport.ps1 -DistributionList -MinGroupMembersCount 500 |
- To get security groups based on the members count,
1 |
./M365GroupReport.ps1 -Security -MinGroupMembersCount 50 |
Microsoft 365 groups are helpful when you want to give access/ send information to multiple people. Adding people to the group automatically gives them the permission they need. Apart from the groups, you can also use shared mailbox membership when multiple people want to access the same mailbox.
AdminDroid Offers Free Advanced Group Reports
AdminDroid provides a comprehensive set of group reports to help you analyze and manage your Microsoft 365 groups efficiently. Gain insights into:
- Group Types – Security, Distribution, Mail-enabled security, Microsoft 365 Groups, Nested Groups, Cloud/Synced Groups, and more.
- Group Membership – Direct members, Nested group members, Hidden membership, External members, Contacts as members, etc.
- Group Member Changes – Track additions and removals.
- Group Usage & Activity – Identify inactive groups based on last activity.
Additionally, Free M365 reporting tool by AdminDroid offers 120+ reports and dashboards completely for free. It includes reports on Users, Licenses, Devices, Login Activities, Password Changes, License Changes, and more. The free edition doesn’t have any restrictions in reporting functionalities such as customization, scheduling, and exporting.
Besides, AdminDroid provides 1900+ pre-built reports and 30+ smart dashboards to know about your Microsoft 365 environment at a glance. This tool provides reports on Office 365 reporting, auditing, analytics, usage statistics, security & compliance, etc.
Download AdminDroid M365 administration tool and witness how it simplifies Microsoft 365 management.
I hope this blog will help you in managing group membership in your organization.