Forum Discussion
pcryan5220
Nov 21, 2023Copper Contributor
Can a Dynamic Distribution list group be created that uses a specific SMTP domain as the filter?
Our corporate Microsoft 365 Exchange environment has users with different SMTP addresses. (e.g., @ work1.com @ work2.com etc.).
Can a Dynamic Distribution list group be created that uses a specific SMTP domain as the filter?
Thank you!
~Peter
- Hm, I hate it when I've overlooked something and Tony gets to be right 😄 Nope, we cannot use -like due to the limitation Tony mentioned. I do however have a working domain-based DDG, with the following filter:
(Get-DynamicDistributionGroup domain).RecipientFilter
((WindowsLiveID -eq '*@michev.onmicrosoft.com')
WindowsLiveID here can be used as a replacement for UPN, and does work for the filter:
[09:34:55][O365]# Get-DynamicDistributionGroupMember domain
Name RecipientType
---- -------------
HuKu UserMailbox
michev_gmail.com#EXT# MailUser
Apologies about the confusion, should have actually checked my setup first.
- As mailboxes can have multiple SMTP address (from different domains) assigned, its best to use something like the UPN value instead:
UserPrincipalName -like '*@domain.com'
but EmailAddresses would also work
EmailAddresses -like '*@domain.com'- pcryanBCCopper ContributorThank you Kidd_IP and Vasil Michev - exactly what I was looking / hoping for.
Much appreciated.
- Wildcards can't be used as the first character in a DDL filter... At least, I have never been able to make this work.
- Hm, I hate it when I've overlooked something and Tony gets to be right 😄 Nope, we cannot use -like due to the limitation Tony mentioned. I do however have a working domain-based DDG, with the following filter:
(Get-DynamicDistributionGroup domain).RecipientFilter
((WindowsLiveID -eq '*@michev.onmicrosoft.com')
WindowsLiveID here can be used as a replacement for UPN, and does work for the filter:
[09:34:55][O365]# Get-DynamicDistributionGroupMember domain
Name RecipientType
---- -------------
HuKu UserMailbox
michev_gmail.com#EXT# MailUser
Apologies about the confusion, should have actually checked my setup first.- The key thing here is that you're using the equals operator instead of like (-eq versus -like). AFAIK, this works for WindowsLiveID but not for any of the other filterable properties that store email addresses.