Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitMaintaining accurate and up-to-date Distribution Lists (DLs) is essential for effective communication within organizations. While Microsoft Graph PowerShell is a robust tool for managing Microsoft 365 Groups, it does not support bulk adding members to Distribution Lists. For that, you must use Exchange Online PowerShell.
In this article, we’ll walk through a script that bulk-adds members to DLs using a simple CSV file, ideal for onboarding or restructuring group memberships.
# Connect to Exchange Online
Connect-ExchangeOnline
# Import CSV containing group-member mappings
$entries = Import-Csv -Path "C:\Users\Thilak\Downloads\dl_members.csv"
foreach ($entry in $entries) {
try {
Add-DistributionGroupMember -Identity $entry.GroupName -Member $entry.MemberEmail
Write-Host "Added $($entry.MemberEmail) to $($entry.GroupName)" -ForegroundColor Green
} catch {
Write-Warning "Failed to add $($entry.MemberEmail) to $($entry.GroupName): $_"
}
}
Ensure your CSV is structured as follows:
GroupName,MemberEmail
Sales Team 0101,user1@7xh7fj.onmicrosoft.com
Sales Team 0101,user2@7xh7fj.onmicrosoft.com
Marketing Team 0101,user3@7xh7fj.onmicrosoft.com
Support Team 0101,user4@7xh7fj.onmicrosoft.com
Each row associates a member with a group. You can include multiple entries for the same group if adding more than one member.
The script starts by establishing a session with Exchange Online using Connect-ExchangeOnline.
Using Import-Csv, the script reads all group-member associations from the CSV file.
A foreach loop reads each line and uses Add-DistributionGroupMember to add the user to the respective group.
If a member addition fails, the script catches the error and logs a warning — ensuring the rest of the script continues running smoothly.
🔄 Graph PowerShell cannot be used for managing traditional Distribution Lists. Tasks like member additions require Exchange PowerShell.
Here are a few ideas to take this script to the next level:
Track which additions succeeded or failed:
"Added $($entry.MemberEmail) to $($entry.GroupName)" | Out-File "DL-Member-Log.txt" -Append
Use Get-User -Identity $entry.MemberEmail before adding to avoid invalid addresses.
Send a success/failure summary to an admin using Send-MailMessage or Send-MgUserMail.
Extend the script to add different roles (managers, assistants) based on department or tags.
Error | Cause | Solution |
---|---|---|
Access is denied | Missing Exchange permissions | Ensure the user has Exchange admin or recipient management role |
Cannot find recipient | Invalid email in CSV | Verify email addresses are accurate and exist in the tenant |
Object not found | Group name doesn't match | Use the Display Name of the DL, not its alias or email |
Already a member | Member already in group | This is safe to ignore; the cmdlet will skip without issue |
While Microsoft Graph PowerShell is the go-to for managing modern Microsoft 365 Groups, Exchange Online PowerShell is still required for managing classic Distribution Lists, especially for bulk member additions.
This script provides a quick, automated way to assign users to their respective DLs using a familiar CSV format — saving time and ensuring consistency.
🛠️ Simple, scalable, and essential for IT admins who manage user communication groups at scale.
© m365corner.com. All Rights Reserved. Design by HTML Codex