Search code examples
powershellactive-directoryexchange-serveremail

set-mailcontact not removing smtp addresses


Hopefully this is a simple one...

Trying to remove unwanted entries in the proxyAddresses from AD objects of type mail contact. I am logged into an exchange server using the exchange shell; no problems there. Here's my one-liner that doesn't seem to do anything:

set-mailcontact -identity Joe_User_Contact -emailAddresses @{remove="[email protected]"}

No errors; but when I browse to the AD object and look at "proxyAddresses", the unwanted entry still exists.

I have also tried:

set-mailcontact -identity Joe_User_Contact -emailAddresses @{remove="smtp:[email protected]"}

To no avail. Does this command not actually do what I think it's supposed to do?

Thanks!


Solution

  • The first command should do exactly what you want, I use it on a regular basis.

    First, I recommend you to check, that the cmdlet really works, try to add an alias.

    Second, it something wrong with the connection to server, try doing

    Connect-ExchangeServer YourServer -AllowClobber

    Third, check that EmailAddressPolicy doesn't prevent you from removing alias (check there policies, especially the lowest - default one) .

    You can simply disable it:

    Set-MailContact [email protected] -EmailAddressPolicyEnabled $false

    Also you can set EmailAddresses attribute with this pattern:

    Set-MailContact [email protected] -EmailAddresses 'SMTP:[email protected]'

    This one will delete all other aliases except the one you wrote (it may require you to disable emailaddress policy).