Powershell Add Secondary SMTP Address in bulk for Exchange Server 2010 SP1
Hello, Is it possible to add secondary smtp address in bulk through local EMS with Powershell in Exchange 2010 SP1 Mailboxes? This is how we used to import from CSV and add secondary smtp addresses in Exchange 2007 SP2. /*************** Create the CSV file as Users.csv add1,add2 address1@domain1.com,address2@domain2.com .....,...... Created a Powershell script for following Import-CSV Users.csv | foreach { $Temp = Get-Mailbox -Identity $_.add1 $Temp.EmailAddresses.Add($_.add2) Set-Mailbox -Instance $Temp } ***************/ We are trying the following for Exchange 2010 SP1 and it DOES NOT seem to work. /*************** Import-CSV Users.csv | foreach { $Temp = Get-Mailbox -Identity $_.add1 $Temp.EmailAddresses += ("smtp:'$_.add2'") Set-Mailbox -Identity $_.add1 -EmailAddresses $Temp.EmailAddresses } ***************/ The error is as follows... Exception setting "EmailAddresses": "Cannot convert value "System.Object[]" to type "Microsoft.Exchange.Data.ProxyAddressCollection". Error: "The address 'smtp:'@{add1=address1@domain1.com; add2=add2@domain2.com'' is invalid: The address ''@{add1=address1@domain1.com; add2=add2@domain2.com}.add2'' is not a valid SMTP address."" At C:\1.ps1:4 char:7 + $Temp. <<<< EmailAddresses += ("smtp:'$_.add2'") + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyAssignmentException Appreciate your assistance. Exchange 2010 SP1 / Powershell 2.0
January 27th, 2011 1:29pm

You can try this: Import-CSV Users.csv | foreach { $Temp = Get-Mailbox -identity $_.Identity $Temp.EmailAddresses.Add($_.EmailAddress2) Set-Mailbox -Instance $Temp } With kind regards Krystian Zieja http://www.projectnenvision.com Follow me on twitter My Blog
Free Windows Admin Tool Kit Click here and download it now
January 27th, 2011 3:59pm

Thanks Krystian. That returns the following error in Exchange 2010 SP1. A positional parameter cannot be found that accepts argument 'User Name'. + CategoryInfo : InvalidArgument: (:) [Set-Mailbox], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Set-Mailbox However, it works fine in Exchange 2007 SP2.
January 27th, 2011 4:25pm

Hi, Assming the csv file has at list this header columns: LoginName and SecondayAddress Import-Csv IDs.csv | Foreach-Object{ $user = Get-Mailbox -Identity $_.LoginName $user.EmailAddresses+=$_.SecondayAddress Set-Mailbox $user -EmailAddresses $user.EmailAddresses }Ravi | MCSE Messaging - 2003. This posting is provided "AS IS" with no warranties, and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
January 27th, 2011 4:50pm

Hi, Please update on the above script, is this worked for you?Ravi | MCSE Messaging - 2003. This posting is provided "AS IS" with no warranties, and confers no rights.
January 28th, 2011 7:58pm

Thank you Ravish. This worked for me.
Free Windows Admin Tool Kit Click here and download it now
January 30th, 2011 8:18am

Hi Ravish, I copied your scripts to a notepad and save it as import.ps1. Import-Csv IDs.csv | Foreach-Object{ $user = Get-Mailbox -Identity $_.Alias $user.EmailAddresses+=$_.SecondaryAddress Set-Mailbox $user -EmailAddresses $user.EmailAddresses } Here is my Csv file format: Alias SecondaryAddress user1 SMTP:user1@domain1.com;smtp:user1@domain2.com;smtp:user1.domain2.com user2 SMTP:user2@domain1.com;smtp:user2@domain2.com:smtp:user2@domain3.com and get the following errors that the SMTP address entry is invalid. How can I put multiple SMTP address in SecondaryAddress field
August 13th, 2011 6:32pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics