đź”§ New: User Management Graph PowerShell Toolkit

Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.

🚀 Launch Toolkit

Bulk Create Distribution Lists or Groups (Exchange PowerShell)

Managing 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.


Script – Bulk Create Distribution Lists

Connect-ExchangeOnline
$groups = Import-Csv -Path "C:\Users\Thilak\Downloads\dls.csv"
foreach ($group in $groups) {
    New-DistributionGroup -Name $group.Name -PrimarySmtpAddress $group.PrimarySmtpAddress
}
                            

CSV Details

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.


How the Script Works

  1. Connects to Exchange Online
  2. The script begins with Connect-ExchangeOnline, allowing you to run mailbox and group management cmdlets.

  3. Reads from CSV
  4. The script uses Import-Csv to load group details from a local CSV file.

  5. Creates Distribution Lists
  6. 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.


Further Enhancements

You can expand this script’s capabilities in several ways:

  • Assign Group Owners or Moderators
  • Add parameters like -ManagedBy, -ModerationEnabled, or -RequireSenderAuthenticationEnabled to control access.

    New-DistributionGroup -Name $group.Name -PrimarySmtpAddress $group.PrimarySmtpAddress -ManagedBy "admin@domain.com"

  • Add Members Automatically
  • Once groups are created, use a follow-up script to import members using Add-DistributionGroupMember.

  • Include Logging
  • Write the output of each creation to a log file for auditing purposes.


Possible Errors & Solutions

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

Conclusion

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.


Graph PowerShell Explorer Widget

20 Graph PowerShell cmdlets with easily accessible "working" examples.


Permission Required

Example:


                


                


                

© m365corner.com. All Rights Reserved. Design by HTML Codex