Multiple Primary SMTP Addresses

Happy 2009 Everyone!

Here at work we have an automated system to create accounts based on data from our ERP system. We noticed after migrated many users to Exchange 2007 from Exchange 2003, that the newly migrated users could not send to users who had forwarded their accounts using UI to our account management system. The error complained of the contact having multiple primary SMTP addresses. Here's the little Powershell code snippet I ran to fix the issue.


foreach ($contact in get-mailcontact -resultsize unlimited){
$a = $contact.ExternalEmailAddress.tostring().Remove(0,5);
set-mailcontact $contact -primarysmtpaddress $a
}