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:
- Sign in new Exchange Admin center and go to Recipients > Groups (https://admin.exchange.microsoft.com/#/groups);
- Go to the Dynamic distribution list tab and click Add a group;
- Choose that you want to create Dynamic distribution group;
- Provide a name and description for the DDG;
- 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;
- 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;
- Then set the unique SMTP address for your dynamic distribution group;
- 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.
Connect to your Exchange Online tenant with the Exchange Online 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'
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')))
To view the members of a Microsoft 365 dynamic distribution group:
(Get-Recipient -RecipientPreviewFilter $DynamicGroup.RecipientFilter).Name
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:
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
2 comments
Hi Cyril, Do you know if its possible to create a Dynamic Distribution Group based on Azure Groups? EG: in my example, it would be valuable to be able to add all users with valid E3 Licences to a distribution.
Hi Cyril! Thank you for sharing such a comprehensive explanation of DDG creation. I must say, it’s quite enlightening. The new EAC brings an exciting feature called the Dynamic Distribution Groups report, which simplifies the management process significantly.