Tuesday, July 22, 2014

Exchange 2010 - Set-MailContact

Today I received a request to upgrade over a 100 contacts to a new external email address as the companies email had change. So for course I would not ever do it manully, and I wrote a script for it. 

$ConfirmPreference = "None"
$contacts = Import-csv 'H:\FILENAME.csv'

Foreach($contact in $contacts)
{
    if($contact.CurrectExternalAddress.Length -gt 0)
    {
        Set-MailContact -Identity $contact.CurrectExternalAddress -ExternalEmailAddress $contact.NewExternalAddress -Confirm:$false -ForceUpgrade
    }


But I just could not get it working automatically, it kept prompting to me to upgrade each contact to 2010. Which is fine, but it was making me press Enter for each change. I looked over it and I tried to do "ConfirmPreference" and "-Confirm:$true/$false" without much success. It wasn't until I read somewhere to try "-Force" that I found the "-ForceUpgrade" which allowed the upgrade to happen without a prompt. 

I honestly had never seen that parameter before. Maybe this will be useful to one of you, and might save you some time.