How to Add Bulk Users to Distribution Group in Office 365 via PowerShell 

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. 

Add bulk users to distribution list csv import

The code and script execution looks similar to the screenshot below. 

add multiple users to distribution group powershell

How to View Distribution Group Members?

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:

export office 365 distribution list members report

Distribution List Summary Report:

get Office 365 distribution group members 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 hope these scripts will save a lot of time for the Office 365 admins. Happy scripting! 

How to Add Bulk Users to Distribution Group in Office 365 via PowerShell 

by Kathy time to read: 1 min
0