Exchange 2010 migration – contacts all have additional email addresses in company domain

After migrating to Exchange 2010 from 2003 we discovered that all the external contacts from the Global Address List (GAL) migrated ok but they all had an extra email assigned with our servers domain.

For example: would have an extra smtp address attached of

In addition any new contacts also had the additional email attached.

Which isn’t ideal so we looked into changing it and came up with a powershell script that would delete the extra emails and prevent them being added again:

# Input variables
$domains = @(“*“)
$ou = “myactivedirectorydomain”

# Removing internal domains from contacts
$domains | foreach {
$domain = $_;
write-host “Preparing for removal of addresses with domain name:” $domain
$Contacts = Get-MailContact -OrganizationalUnit $ou -Filter {
                EmailAddresses -like $domain -and name -notlike “ExchangeUM*”
            } -ResultSize unlimited -IgnoreDefaultScope
$Contacts | foreach {      
    $contact = $_;
    $email = $contact.emailaddresses;
    #write-host “1. ” $contact
    #write-host “2. ” $
    #write-host “3. ” $email
    #write-host “4. ” $contact.identity
    $email | foreach {
        if ($_.smtpaddress -like $domain)
                $address = $_.smtpaddress;
                write-host “[*] Removing address” $address “from Contact” $;
                Set-Mailcontact -Identity $contact.identity -EmailAddresses @{Remove=$address};


# Setting up email address policy to disabled for all contacts
write-host “Preparing all contacts for disabling email address policy”
$Contacts = Get-MailContact -OrganizationalUnit $ou -Filter {
                EmailAddresses -like $domain -and name -notlike “ExchangeUM*”
            } -ResultSize unlimited -IgnoreDefaultScope | Where {$_.EmailAddressPolicyEnabled  -eq $true}
$Contacts | foreach {
    $contact = $_;
    write-host “[*] Setting up email address policy to disabled for” $
    $contact | set-mailcontact -emailaddresspolicyenabled $false

The first part of the script cycles through the contacts deleting the emails with the domain set in the $domains variable – replace ‘’ with your own domain and change the $ou to the correct active directory domain and out e.g.

The second part changes the default email policy which is what causes the extra smtp addresses to be added.

If you add new contacts via console then you do not need to run this again as you would not apply the default email policy but if you are adding contacts using an older script you may experience this problem and would therefore have to run again – perhaps on a scheduled basis.

Nice one Microsoft {:-|

Author: James

IT Manager - Network, Web coding, MS SQL and Online Mapping expert

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: