O365 Dynamic distribution group filters

lee roberts 186 Reputation points
2021-07-22T15:52:00.447+00:00

I'm trying to create a dynamic distribution list in exchange online based on the email domain. The below is what i have but it returns all user not just the users i want

Set-DynamicDistributionGroup -Identity "Users" -RecipientFilter "(RecipientType -eq 'UserMailBox') -and (EmailAddresses -like 'SMTP:*domain.com')" -PrimarySmtpAddress "Users@domain.com" 

We have multiple domains in our tenant

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,521 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 46,711 Reputation points
    2021-07-22T18:39:22.467+00:00

    Shouldn't that filter look like this?

    EmailAddresses -like 'SMTP:*@keyman .com'

    Is it possible that all your domains are similar and they all end in "domain.com"? E.g. sub1.domain.com, sub2.domain.com, and domain.com. Or ABCdomain.com, DEFdomain.com, and domain.com,

    This more of an Exchange question than a PowerShell question.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.