reason

Well, I can't remember everything...

Wednesday 3 February 2016

Stopping the Default Email Address Policy applying to MailUsers and MailContacts, and removing the excess email addresses you accidentally added

The Default Email Address Policy applies to every object in Exchange. This will include any MailContacts or MailUsers you have created. To work around this, try the following:

First, make sure you have an Email Address Policy created for your own users. This will apply to Exchange mailboxes, Resource mailbox and any Mail-enabled groups. This will have a priority of 1

Now for the workaround.

Create a new dummy Accepted Domain

New-AcceptedDomain -Name "External Contacts" -DomainName external.contacts

Now create a new Email Address Policy

New-EmailAddressPolicy -Name "External Contacts" –EnabledPrimarySMTPAddressTemplate "SMTP:%m@external.contacts" -IncludedRecipients "MailContacts,MailUsers" -Priority 2

This will assign the email address alias@external.contacts to any future MailContacts or MailUsers

Now to remove all the additional email addresses from MailUsers and MailContacts you may have accidentally added...

The command below, will remove all email addresses, apart from the primarysmtpaddress

get-mailuser |foreach {set-mailuser -identity $_.identity -emailaddresses "SMTP:$($_.primarysmtpaddress)"}

If you get any permission errors, you need to Enable Inheritance in Security settings of their AD object

You can check to see what email addresses a MailUser has with

get-mailuser | fl identity,primarysmtpaddress,emailaddresses

Now replace get-mailuser with get-mailcontact, and set-mailuser with set-mailcontact in the commands above to complete the process



No comments:

Post a Comment