How to Add Bulk Users to Distribution Group in Office 365 via PowerShell
This blog helps admins add multiple members to the distribution group using PowerShell. The script accepts bulk users through import CSV and adds those users to the distribution list.
Note: This script uses the PowerShell cmdlet Add-DistributionGroupMember. Before running the script, you must install the Exchange Online Management module.
Connect-ExchangeOnline Import-CSV <FilePath> | foreach { $UPN=$_.UPN Write-Progress -Activity "Adding $UPN to group… " Add-DistributionGroupMember –Identity <GroupUPN> -Member $UPN If($?) { Write-Host $UPN Successfully added -ForegroundColor Green } Else { Write-Host $UPN - Error occurred –ForegroundColor Red } }
The input CSV file should follow the format below.
The code and script execution looks similar to the screenshot below.
Removing bulk users from DL is similar process to adding users to DL. To remove bulk users, you can use the below code.
Connect-ExchangeOnline Import-CSV <FilePath> | foreach { $UPN=$_.UPN Write-Progress -Activity "Removing $UPN from the group… " Remove-DistributionGroupMember –Identity <GroupUPN> -Member $UPN If($?) { Write-Host $UPN Successfully removed -ForegroundColor Green } Else { Write-Host $UPN - Error occurred –ForegroundColor Red } }
Finding out who is member of which Distribution Group is always a tiresome task. To make it simple, you can use the pre-built script to generate distribution group members report.
Sample Output:
The script exports 2 output files; one with detailed info and another with summary report.
Detailed Distribution List Members Report:
Distribution List Summary Report:
Script Highlights:
- Allows you to filter the report result based on group size(i.e., Members count).
- The script can be executed with MFA enabled account too.
- You can choose to either “Export Members of all Distribution Lists” or pass an input file to “Export Members of Specific Distribution Lists”.
- You can filter the output based on whether the group accepts messages from external senders or not.
- Exports the list of allowed senders to a Distribution List.
- Output can be filtered to list Empty group. i.e., Distribution Group without members
- Exports the report result to CSV.
- You can get members count based on Member Type such as User mailbox, Group mailbox, Shared mailbox, Contact, etc.
- The script is scheduler-friendly. i.e., credentials can be passed as parameters instead of saving inside the script.
- Above all, the script exports output in nicely formatted 2 CSV files. One with detailed information and another with summary information.
I believe that the above PowerShell scripts can be more efficient in generating a comprehensive distribution group membership report. However, getting more specific details on the added M365 distribution groups will eat up your time and won’t yield the desired results.
Hooray! What if we told you there is a free, user-friendly reporting solution that simplifies this process? 💆 Yes! AdminDroid, a free Azure AD reporting tool, is designed to empower Microsoft 365 administrators.
Forget about wrestling with scripts to generate your distribution group membership reports. With AdminDroid, you can quickly pull up comprehensive Microsoft 365 group details at no cost and without any delay. 👏
You can get the complete distribution group members’ list along with the details such as group email, member type, members’ emails, departments, etc., with the report below.
AdminDroid is not merely a reporting tool but an avenue to level up your Microsoft 365 group management. It also features 10+ group-related reports, including all types of Office 365 groups and other reports such as user reports, license reports, password reports, etc.
In addition to the above, it offers a plethora of visually striking 30+ dashboards 📊and 1600+ insightful reports for various Microsoft 365 services like Exchange Online, SharePoint Online, Microsoft Teams, OneDrive, Yammer, etc.
So, why stick to the conventional, time-consuming methods when AdminDroid can simplify your Azure AD management? Experience the future of Azure AD today with AdminDroid – it’s more than just a tool; it’s your ticket for efficient Microsoft 365 administration! 💡