Create a Dynamic Distribution List in Microsoft 365 to include all users’ mail addresses automatically

Almost all organizations need an all staff distribution list to send notification to all employees. Traditional way is to have somebody (usually HR or IT) to update the list when recruiting new employee or retention happens. This adds up human work loading and is error prone.

Create a dynamic mail list is easy with Microsoft 365 Exchange Online

Actually in Microsoft 365 there is a feature called dynamic distribution list which can fit the needs perfectly with a few clicks:

  1. Log into exchange online admin console:
  2. Add group, select Dynamic distribution
  1. go to next and select proper users you want
  • Users with Exchange mailboxes: Select this check box if you want to include users that have Exchange mailboxes. Users that have Exchange mailboxes are those that have a user domain account and a mailbox in the Exchange organization. Note that resource mailboxes are also included.
  • Mail users with external email addresses: Select this check box if you want to include users that have external email addresses. Users that have external email accounts have user domain accounts in Active Directory, but use email accounts that are external to the organization. This enables them to be included in the global address list (GAL) and added to distribution lists.
  • Resource mailboxes: Select this check box if you want to include Exchange resource mailboxes. Resource mailboxes allow you to administer company resources through a mailbox, such as a conference room or a company vehicle.
  • Mail contacts with external email addresses: Select this check box if you want to include contacts that have external email addresses. Contacts that have external email addresses don’t have user domain accounts in Active Directory, but the external email address is available in the GAL.
  • Mail-enabled groups: Select this check box if you want to include security groups or distribution groups that have been mail-enabled. Mail-enabled groups are similar to distribution groups. Email messages that are sent to a mail-enabled group account will be delivered to several recipients.

After select Mail users with external email addresses and click next you have successfully created a dynamic group mail list to include all active mailbox (note: not all employees).

Change the rule of dynamic distribution list further

That works in common circumstances but if there is SharedMailbox you will find that mails will be sent to SharedMailbox as well. This is a bit annoying to some perfectionist who wants to minimize mails, especially duplicate mails, he reads everyday.

You have to turn to powershell to manage dynamic distribution list with micro filters. Steps I take are as following:

  1. Connect to Microsoft 365:
    • Connect-ExchangeOnline -UserPrincipalName your login id
  2. Assign the list to a variable:
    • $FTE = Get-DynamicDistributionGroup the list mail address
  3. Check who will receive mail from the list, you will find that all UserMailboxes are included.
    • Get-Recipient -RecipientPreviewFilter $FTE.RecipientFilter  | Sort-Object -Property Name
  4. The reason is that the list filter uses RecipientType instead of RecipientTypeDetails. SharedMailbox’s RecipientType is UserMailbox when its RecipientTypeDetails is SharedMailbox. We can get list filter criteria by:
    • $FTE.RecipientFilter 
  5. To change and exclude SharedMailbox we just need:
    • Set-DynamicDistributionGroup -identity  $FTE.Identity  -RecipientFilter  {(RecipientTypeDetailsValue -eq 'UserMailbox') }
  6. Remember to repeat step 2 and 3 to verify the result.

We have rich experience in managing Microsoft 365 to fully utilize the power, including SharePoints, Mail verified Sharing, Multi Factor to prevent phishing mail to crack into your organization. Please fill the contact form or drop us a call.