Exchange Powershell Script for exporting email addresses


I'm looking for a way of using powershell to export all email aliases associated with an individual mailbox to a CSV file.

I am then looking for another powershell script to import that information to a different mailbox. The mailbox is in a different Exchange forest which is sharing the SMTP namespace so there will be no conflict of proxy addresses.

Thanks in advance
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
Use the following command to export the user mailboxes which references the Alias and PrimarySMTPAddress, and export the results to CSV
Get-Mailbox -ResultSize "unlimited" | Select Alias, PrimarySmtpAddress |
Export-csv "c:\mailboxes.csv" -nti

Open in new window

Thats it.

vmdudeAuthor Commented:
Hi Will,

Thanks for your comment, however I am looking to export all aliases for a specific user to CSV.
So for example;

I know a user called Joe Bloggs has got 30 email addresses as other admins have un-checked the "Automatically update e-mail addresses based on email address policy" and have manually added a world of other adresses.

What I want to do is export all email addresses associated with Joe Bloggs to a CSV and then take that CSV and import to a new user (also called Joe Bloggs) in a different forest.
Mahmoud SabrySenior IT Systems EngineerCommented:
you can use the below script instead

Get-Mailbox -ResultSize "unlimited" | Select Alias, EmailAddresses

then open the transcript file (u will see the path in the command shell) and you can use it
Check Out How Miercom Evaluates Wi-Fi Security!

It's not just about Wi-Fi connectivity anymore. A wireless security breach can cost your business large amounts of time, trouble, and expense. Plus, hear first-hand from Miercom on how WatchGuard's Wi-Fi security stacks up against the competition plus a LIVE demo!

Will SzymkowskiSenior Solution ArchitectCommented:
Easy.... use the following command below...
Get-Mailbox -Identity "Joe Bloggs" | Select -ExpandProperty EmailAddresses | Select SmtpAddress |
Export-csv "c:\Addresses.csv" -nti

Open in new window

That should do it for a single user. If you want to do this for multiple users let me know.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vmdudeAuthor Commented:
Hi Will,

Yes that is exactly what I am after thank-you. Final question then... how do I take that information and import it to the new user?
Will SzymkowskiSenior Solution ArchitectCommented:
Not sure why you graded this answer a B if it was exactly what you were looking for. You never gave me an opportunity to answer your last comment. However this would be considered a new question, so it should be opened and i would be glad to assist with that.

vmdudeAuthor Commented:
Hi Will,

Fair comment, I will see if I can retract and upgrade to A
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.