I'm trying to create a dynamic distribution list that includes only user mailboxes whose primary email address ends in @domain.org. I tried filtering on both PrimarySmtpAddress and WindowsEmailAddress, but Exchange rejects the filter with an error saying wildcards cannot be used as the first character. Using an SMTP wildcard allowed the group to be created, but messages appeared as delivered and expanded in message trace while none of the members received them. What is the supported way to build this type of group?
3 Answers
In Exchange Online, filtering dynamic groups directly by email address is no longer supported because of performance and reliability concerns. The practical alternatives are to maintain a regular distribution group with an automated script, or populate an extension attribute for each user and filter on that attribute instead. The attribute must be kept updated whenever users are added or their domain changes.
A static distribution group with scheduled automation is usually the safest option. A script can find all matching user mailboxes and add or remove members as needed. If you want to keep the group dynamic, assign a value such as the user’s email domain to an extension or custom attribute, then use that attribute in the recipient filter instead of filtering on the SMTP address.
The PowerShell line breaks are not the main issue here. Splatting can make the command easier to read, but it won’t bypass the restriction on leading wildcards in Exchange recipient filters. Also, a filter using an address wildcard may create a group that expands without successfully selecting the intended recipients, which matches the delivery behavior you observed.

That explains the wildcard error. I’ll look into using an extension attribute or automating membership in a standard group.