Export Microsoft 365 Group Report to CSV Using PowerShell 

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. 

PowerShell has several cmdlets like Get-MSolGroup, Get-AzureADGroup, Get-UnifiedGroup, Get-DistributionGroup to get group information. Are you confused to pick the correct one? Fear not! We are here to help you. We have created an All-in-One PowerShell script to export groups and their membership details to CSV file. 

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 group report for single/list of groups (through CSV import) 
  • Get group membership for a single/list of groups (through 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 (Group report based on the member count report) 

 

Download Script: M365GroupReport.ps1 

 

Additional Highlights of the Script: 

  • The script can be executed with MFA enabled account 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. i.e., credentials can be passed as parameter instead of saving inside the script. 
  • 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 PowerShell Script – Execution Steps: 

Step 1: Download the script.  

Step 2: Start Windows PowerShell as Administrator.   

Step 3: To view all the groups and their members’ info, run the script as follows: 

After the script execution, both output files will be available in the execution directory. 

Note: You can use the above syntax to execute the script with both MFA and non-MFA account. 

 

Microsoft 365 Group Report: 

The Microsoft 365 Group report has the following columns: Group Name, Email Address, Group Type, Group Members Count, and Members Count by Type. 

The group report looks similar to the screenshot below: 

Microsoft 365 group report

 

Microsoft 365 Group Membership Report: 

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. 

The group members report looks similar to the screenshot below: 

Office 365 group membership report

 

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. 

Export all Microsoft 365 Groups and Membership to CSV: 

To export all the Microsoft 365 groups, execute the script as follows: 

The exported report contains all the group types such as Distribution List, Security Groups, Mail-enabled Security group and Unified groups. 

By referring to this report, admin can add or remove user from the group. 

 

Get Members for a Single/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. 

The GroupIDsFile must follow the format below:  Group identity separated by new line without header. 

Office 365 group report

 

Group Size Report: 

The report helps you to get the groups that have more than an ‘N’ number of members. To get this report, you can execute the script with MinGroupMembersCount param. 

The above script exports all groups that have more than 50 members. 

Note: If you want to determine group membership (I.e., members count) based on certain conditions, you can use Dynamic Group membership report. 

 

Microsoft 365 Security Group Report: 

Security groups are used for granting access to Microsoft 365 resourcesTo export security group report, you can run the script with –Security param.  

By referring group membership report, you can view the users who has rights and access to SharePoint sites and CRM Online 

 

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. 

The above script lists all the distribution groups and their members info.  

NoteThe report lists Microsoft 365 groups (group mailboxes) as a Distribution List. 

You can also check our dedicated script on the Distribution Group membership report for more detailed report. 

 

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. 

The script exports mail-enabled security groups info and membership to the CSV file. 

 

Get Empty Groups Report: 

To get an empty group report (i.e., groups without members), execute the script with IsEmpty param. 

By referring to this report, you can delete unused/inactive groups in your tenant. 

 

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 use Windows Task Scheduler for PowerShell scheduled task. 

 

Get more Granular Group Report: 

To export 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, 

 

  • To view empty security groups, 

 

  • To list empty mail-enabled security groups, 

 

  • To get large distribution groups, 

 

  • To get security groups based on the members count, 

 

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. 

 

I hope this blog will help you in managing group membership in your organization.