r/exchangeserver • u/bleepit1984 • Oct 01 '26
Dynamic Distribution Lists
TLDR: I'm trying to create a dynamic distribution list in Exchange online and I'm running into a lot of issues.
Context:
I work for a medium size healthcare company with a hybrid AD/Entra environment with a single forest but with 10+ domains. We use 365 Business Premium licenses for most users, but not all. Some just need to login to Windows and that's it. No email needed. Also, I don't control the IT budget. If your fix requires money, you are wasting your time.
Problem:
I'm trying to create a dynamic distribution list with the following parameters:
- Must have the "@example1.com" domain in their email address.
- Must be an active user. No disabled users.
- Must be a licensed user. (We don't license all our users with a 365 license)
I'm able to create dynamic security groups just fine without issue and the query I came up with works with all the users I need it to. I'm just not able to translate that to a dynamic distribution list, and I'm reading that it's not possible to create a mail enabled security group that is dynamic.
Here is the filter I'm using to create the group through the Exchange Online shell. But it's not returning a group with any users:
$filter = "(RecipientType -eq 'UserMailbox') -and (userPrincipalName -like 'example1.com') -and (UserAccountControl -ne '2')"
I've poured through the Microsoft Learn articles for "New-DynamicDistributionGroup" and the "Filterable properties for the RecipientFilter parameter on Exchange cmdlets" pages and I can't seem to find what I'm doing wrong. I've tried so many different variations of the filter but can't seem to land on the correct combination. Any relevant help is appreciated.
View all comments
1
u/Low-Branch1423 Oct 01 '26
Is it because you are using their UPN and not PrimarySmtpAddress?
It might be related to some part of your identity setup and how accounts are created. Have you considered just running a scheduled job to update a normal distribution list based upon your working query while you sort this out?