Exchange Online Distribution Group Delivery Management

I recently carried out a large migration and my customer had 700 Distribution Groups. My customer asked me to restrict delivery of emails to the groups by members only. So end users could not email the distribution group unless they were a member. 

So how do I do this for 700 users!! Powershell to the rescue.

Connect to Exchange Online via Powershell and run this command.

  1. Get-Distributiongroup | export-csv C:\users\disti.csv
  2. I then deleted all columns in the csv except for PrimarySmtpAddress and then renamed that column to distiname.
  3. Then run this command
    Import-Csv “C:\Users\sofarrell\Desktop\disti.csv” | Foreach-Object{get-distributiongroup $_.distiName | Set-distributiongroup -AcceptMessagesOnlyFromDLMembers $_.distiname}
  4. And then run this command
    Import-Csv “C:\Users\sofarrell\Desktop\disti.csv” | Foreach-Object{get-distributiongroup $_.distiName | Set-distributiongroup -AcceptMessagesOnlyFromSendersOrMembers $_.distiname}
Job done , Happy Customer.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s