I have a number of users in our 2010 Exchange server. I wish to export (into a file) all the email addresses for a particular user. Later on, I wish to be able to import all the email addresses once more into the user (lets assume all the emails to be imported do NOT exist in any user account).

Anyone have any ideas how to do this?

Powershell magic, anyone?

  • I'm intrigued as to why you might want to do this? – Ben Pilbrow Jan 9 '11 at 22:37
  • A user wishes to see all their email addys. next, they wish to bulk import missing ones. They can easily do this in excel, hence the export. – Pure.Krome Jan 9 '11 at 23:11
  • Argh, I have a script that does something similar.... somewhere! I just can't find it at the minute. If I remember, I'll have a look through the SVN repo at work tomorrow to see if I can find it. I assume there's lots of aliases, so manually doing it is a no go? – Ben Pilbrow Jan 9 '11 at 23:32
  • Correct. the first person i looked at had around 60 odd. Also sucks how I can't figure out how a user can add an alias via their OWA or Outlook -- currently they have to send admin (my team) and email request to add one. – Pure.Krome Jan 9 '11 at 23:43
  • Any luck finding that script? – Pure.Krome Jan 11 '11 at 0:37

I figured out the answer.

In exchange powershell ...

> $mbx = Get-Mailbox someUserName
> $mbx.EmailAddresses | where { $_.IsPrimaryAddress -eq "False" } | Export-CSV "C:\SomePath\wherever.csv"
> $mbx.EmailAddresses | where { $_.IsPrimaryAddress -eq "False" } | foreach { $mbx.EmailAddress -= $_.SmtpAddress }
> Set-Mailbox someUserName -EmailAddresses $mbx.EmailAddresses

> $mbx = Get-Mailbox theNewUser
> Import-CSV "C:\SomePath\wherever.csv" | foreach { $mbx.EmailAddresses += $._SmtpAddress }
> Set-Mailbox theNewUser -EmailAddresses $mbx.EmailAddresses

that's it :)

Of course, you might need to modify the contents of the csv file after the export and before the import.

I also had to delete all the existing email's from the someUserName so there were no duplicates in theNewUser

good luck :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.