how to import multiple SMTP addresses using Exchange 2007 SP3 powershel;
Hello there I copied Ravish's 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 Thanks a lot.
July 28th, 2011 6:46pm

Have you tried to create a EAP and used a filter? Have you create an accepted domain for the other domains? Sukh
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2011 6:56pm

Not tested: Import-Csv IDs.csv | Foreach-Object{ $user = Get-Mailbox -Identity $_.Alias $user.EmailAddresses+=($_.SecondaryAddress -split ";") Set-Mailbox $user -EmailAddresses $user.EmailAddresses } That should give you an array of address from the semi-colon delimited list. It may not like having that first one there with the SMTP (caps) prefix. That denotes the primary SMTP address, and there's already going to be one in the user email addresses.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
July 28th, 2011 7:05pm

here is the easier way to do it. just break up the muti-value attribute. ---------------------------- Get-Mailbox -resultsize 9999| Select Name, @{Name=’EmailAddresses’;Expression={[string]::join(",", ($_.EmailAddresses))}} | Export-CSV c:\EmailAddress.csvgot a question? guarantee answers at: http://www.infotechguyz.com/forum/
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2011 7:27pm

Thanks for quick reply... I get the following error: You must provide a value expression on the right-hand side of the '-' operator. At D:\Program Files\Microsoft\Exchange Server\Scripts\import.ps1:3 char:48 + $user.EmailAddresses+=($_.SecondaryAddress -s <<<< plit ";") [PS] C:\scripts>
July 28th, 2011 7:30pm

Let's try a different tack: Import-Csv IDs.csv | Foreach-Object{ $user = Get-Mailbox -Identity $_.Alias $user.EmailAddresses += (($_.SecondaryAddress).split(";")) Set-Mailbox $user -EmailAddresses $user.EmailAddresses } [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2011 7:35pm

here is the error: [PS] C:\scripts>import.ps1 You cannot call a method on a null-valued expression. At D:\Program Files\Microsoft\Exchange Server\Scripts\import.ps1:3 char:56 + $user.EmailAddresses += (($_.SecondaryAddress).split( <<<< ";")) You cannot call a method on a null-valued expression. At D:\Program Files\Microsoft\Exchange Server\Scripts\import.ps1:3 char:56 + $user.EmailAddresses += (($_.SecondaryAddress).split( <<<< ";"))
July 28th, 2011 7:41pm

That's telling us that $_.SecondaryAddress is null. It doesn't seem to like that .csv file. Are you sure those column headings are right, and there's no leading or trailing spaces in them?[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2011 7:55pm

sorry. My mistake. the script works great. Thanks all for your input and help. BTW, SMTP entry works fine since I uncheck EAP option.
July 28th, 2011 8:02pm

No problem. Glad you got it to work :).[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2011 8:03pm

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

Other recent topics Other recent topics