r/PowerShell • u/No_Concentrate2648 • May 07 '26
Creating Dynamic DL for user mailboxes only with a specific domain
Hi all,
I'm trying to create a Dynamic DL for user mailboxes only with a specific domain, for this I tried the Powershell commands below:
When I try this, I get the error below:New-DynamicDistributionGroup `
-Name "domain all" `
-Alias "domainall" `
-RecipientFilter "(RecipientTypeDetails -eq 'UserMailbox') -and (PrimarySmtpAddress -like '*@domain.org')"But when I try this, I get the error below:
||Wildcards cannot be used as the first character. Please revise the filter criteria.Afterwards I did some research and tried the commands below:
New-DynamicDistributionGroup `
-Name "domain all" `
-Alias "domainall" `
-RecipientFilter "(RecipientTypeDetails -eq 'UserMailbox') -and (WindowsEmailAddress -like '*@domain.org')"but I keep getting the same error about the Wildcard stuff. Does anyone know what I am doing wrong or what I can do to solve this?
Apparently it's failing because you can't start with "*", I tried adding SMTP:*domain.org instead. Then it did create the DL but when users send an email to the DL, nobody receives it while the message trace says it's delivered and expanded.
Does anyone know what I am doing wrong? Thank you guys in advance!