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?

BastianW
  • 2,848
  • 4
  • 19
  • 34
SausageBuscuit
  • 165
  • 1
  • 11
  • 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 '15 at 08:16
  • I get "Wildcards cannot be used as the first character. Please revise the filter criteria." – SausageBuscuit Jun 18 '15 at 16:07
  • This is absolutely wild that it is 2022 and the wildcards issue is still here. What is Microsoft even doing? – Arrow_Raider Sep 20 '22 at 13:53

1 Answers1

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.

SausageBuscuit
  • 165
  • 1
  • 11