3

We have Exchange online with Office 365. I am trying to set up a dynamic distribution list of external mail contacts if their address contains a certain email domain. I have tried the powershell script below (as well as the WindowsEmailAddress and EmailAddresses attributes instead of External) but can not get it to work. Anyone know how I could accomplish this? With Exchange Online, it has to be done in Powershell.

Set-DynamicDistributionGroup -Identity "Test Group" -RecipientFilter {((RecipientType -eq 'MailContact') -and -(ExternalEmailAddress -like '@example.com'))}

From what I can tell, the email address filter doesn't seem to be working. The domain is definitely correct. Is there an attribute that can check email addresses for Mail Contacts?

3
  • 1
    There is a "-" in front of "(ExternalEmailAddress [...]" that needs to be removed. When using -like you have to use a wildcard character. Please try ExternalEmailAddress -like '*@example.com'
    – megamorf
    Jun 15, 2015 at 8:16
  • I get "Wildcards cannot be used as the first character. Please revise the filter criteria." Jun 18, 2015 at 16:07
  • This is absolutely wild that it is 2022 and the wildcards issue is still here. What is Microsoft even doing? Sep 20, 2022 at 13:53

1 Answer 1

0

I have resorted to using the Company attribute and doing this:

Set-DynamicDistributionGroup -Identity "Test Group" -RecipientFilter     
{((RecipientType -eq 'MailContact') -and (Company -eq 'Example'))}. 

Will be one extra step per person but since that other filter has been so much trouble I'm fine with it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .