How to Create Dynamic Distribution Groups in Microsoft (Office) 365

A distribution group in Exchange is a special type of object that is assigned a unique SMTP address. A distribution group can include other users, shared mailboxes, contacts, and other types of objects that have an e-mail address. When an e-mail message is sent to a distribution group address, it is automatically forwarded to the e-mail addresses of all members (subscribers).

Exchange allows you to create static and dynamic distribution groups. The membership of a static distribution group is formed manually by adding users to the group. Membership in a dynamic distribution group (DDG) is not permanent and depends on the filters and conditions configured. For example, you can create a dynamic group of users whose Department attribute is set to IT, etc. In this article, we’ll show you how to create dynamic distribution groups in Microsoft 365 (Exchange Online).

Let’s look at how to create a new dynamic distribution group in Microsoft 365 using EAC:

  1. Sign in new Exchange Admin center and go to Recipients > Groups (https://admin.exchange.microsoft.com/#/groups);
  2. Go to the Dynamic distribution list tab and click Add a group; office 365 dynamic distribution group
  3. Choose that you want to create Dynamic distribution group;
  4. Provide a name and description for the DDG;
  5. Next, you need to set the owner of the groups and configure the rules that will be used to add recipients to this group. In our example, we want to create a dynamic group of users from the “Engineering” department of “TheITBros” company;
  6. Configure the following rules:
    Recipient types:
    Users with Exchange mailboxes, Resource mailboxes, Mail users with external email addresses, and mail contacts.
    Select conditions:
    Department > Engineering
    Company > TheITBros
    Click Next;
    o365 dynamic distribution group
  7. Then set the unique SMTP address for your dynamic distribution group;
    create dynamic distribution group
  8. Click Next > Create group.

Only the most common filters can be created through the EAC graphical console. If you need to use logical operators other than AND, you need to use PowerShell to manage the DDG.

ADVERTISEMENT

Connect to your Exchange Online tenant with the ExO v2 PowerShell module:

Connect-ExchangeOnline

To display a list of dynamic groups in EOL tenant, run the command:

Get-DynamicDistributionGroup

To get your DDG:

$DynamicGroup = Get-DynamicDistributionGroup 'AllEngineers'

create dynamic distribution group office 365

View the filter that is used to add recipients to a group:

$DynamicGroup.RecipientFilter

In our example, when creating a DDG through the Exchange Admin Center console, a rather complex filter was used:

((((Department -eq 'Engineering') -and (Company -eq 'TheITBros') -and (((RecipientType -eq 'UserMailbox') -or (RecipientType -eq 'MailContact') -or (RecipientType -eq 'MailUser') -or (((RecipientType -eq 'UserMailbox') -and (ResourceMetaData -like 'ResourceType:*') -and (ResourceSearchProperties -ne $null))))))) -and (-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and (-not(RecipientTypeDetailsValue -eq 'MailboxPlan')) -and (-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'PublicFolderMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuxAuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'SupervisoryReviewPolicyMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'GuestMailUser')))

create a dynamic distribution group

To view the members of a Microsoft 365 dynamic distribution group:

(Get-Recipient -RecipientPreviewFilter $DynamicGroup.RecipientFilter).Name

create dynamic distribution group in o365

Let’s try adding a single email address to a dynamic distribution group. We will use the -OR logical operator to add a direct group member:

$newrcptfilter="(((Department -eq 'IT') -and (Company -eq 'TheITBros')) -or (PrimarySmtpAddress -eq 'admin@theitbros.com'))"

Now apply the filter:

ADVERTISEMENT
Set-DynamicDistributionGroup -Identity 'AllEngineers' -RecipientFilter $newrcptfilter

Please note that DDG membership is renewed approximately every 24 hours. You can view the last update time as follows:

(Get-DynamicDistributionGroup -Identity 'AllEngineers').CalculatedMembershipUpdateTime

If you want to force membership refresh in a dynamic distribution group:

Set-DynamicDistributionGroup -Identity 'AllEngineers' ForceMembershipRefresh
I enjoy technology and developing websites. Since 2012 I'm running a few of my own websites, and share useful content on gadgets, PC administration and website promotion.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.