Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitManaging email distribution lists (DLs) is an essential task in Microsoft 365 administration — especially when setting up or migrating user communication structures. While Microsoft Graph PowerShell is powerful, you cannot use it to create or bulk-create Distribution Lists. For this task, Exchange Online PowerShell is required.
This article provides a simple yet effective script to bulk-create Distribution Lists (DLs) using Exchange PowerShell, along with an example CSV file you can modify and reuse.
Connect-ExchangeOnline
$groups = Import-Csv -Path "C:\Users\Thilak\Downloads\dls.csv"
foreach ($group in $groups) {
New-DistributionGroup -Name $group.Name -PrimarySmtpAddress $group.PrimarySmtpAddress
}
Make sure your CSV file (in this case named dls.csv) is structured as follows:
Name,PrimarySmtpAddress
Sales Team 0101,salesteam0101@7xh7fj.onmicrosoft.com
Marketing Team 0101,marketing0101@7xh7fj.onmicrosoft.com
Support Team 0101,support0101@7xh7fj.onmicrosoft.com
Save the file in a known location like C:\Users\YourName\Downloads\dls.csv and update the script path accordingly.
The script begins with Connect-ExchangeOnline, allowing you to run mailbox and group management cmdlets.
The script uses Import-Csv to load group details from a local CSV file.
The foreach loop processes each row in the CSV, calling New-DistributionGroup to create each DL using the provided name and SMTP address.
âť— Microsoft Graph PowerShell does not support creation of Distribution Lists (DLs). This task must be done using Exchange Online PowerShell, as shown above.
You can expand this script’s capabilities in several ways:
Add parameters like -ManagedBy, -ModerationEnabled, or -RequireSenderAuthenticationEnabled to control access.
New-DistributionGroup -Name $group.Name -PrimarySmtpAddress $group.PrimarySmtpAddress -ManagedBy "admin@domain.com"
Once groups are created, use a follow-up script to import members using Add-DistributionGroupMember.
Write the output of each creation to a log file for auditing purposes.
Error | Cause | Solution |
---|---|---|
New-DistributionGroup is not recognized | Not connected to Exchange Online | Run Connect-ExchangeOnline first |
PrimarySmtpAddress already in use | Duplicate SMTP address in tenant | Ensure all email addresses in CSV are unique |
Access Denied | Insufficient permissions | Ensure the account is a recipient administrator or Exchange admin |
Cannot bind parameter | Typo in CSV column headers | Use exact header names: Name, PrimarySmtpAddress |
Although Microsoft Graph PowerShell is powerful for modern group management, it does not support creating Distribution Lists (DLs). For this, you’ll need to rely on Exchange Online PowerShell, as demonstrated in this article.
Using a simple CSV file and a few lines of code, you can bulk-create DLs quickly and reliably — ideal for onboarding, migrations, or restructuring communication groups in your Microsoft 365 environment.
đź’ˇ Keep this method handy when you need to set up multiple email-enabled distribution groups without hassle.
© m365corner.com. All Rights Reserved. Design by HTML Codex