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?

  • 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 8:16
  • I get "Wildcards cannot be used as the first character. Please revise the filter criteria." – SausageBuscuit Jun 18 '15 at 16:07

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.