Exporting email addresses into .CSV of around 20 mailboxes?

Hi guys,

If we wanted to export the email addresses of lets say around 20 mailboxes into a .CSV, how would we do that in Exchange 2010 shell?

For example, if we have a list of the name of the mailboxes like the below, then what would be the best way to export their email addresses without having to do each one individually?


Thanks a lot
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.

FOXActive Directory/Exchange EngineerCommented:
If you have the list of users/mailboxes in a list.   Name the list mailboxes.txt  Your exchange shell command will be

 Get-Content "c:\filepath\mailboxes.txt" | Get-Mailbox | Ft SamAccountName, EmailAddress | out-file "c:\temp\emailaddresses.csv"

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
Tej Pratap Shukla ~DexterServer AdministratorCommented:
Run below command in EMS to export email addresses to CSV file:
Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Export-Csv c:\mailbox_alias.csv

Open in new window

YashyAuthor Commented:
Fabulous guys, thanks for your help.
Todd NelsonSystems EngineerCommented:
First, create a CSV file with a list of the users you want to output email addresses for.  I called the file "MailboxList.csv".  The CSV must have a header and look similar to this...


Next run these two commands...

The first will import the information using "MailboxList.csv" into an array.

$MyAddresses = Import-Csv "C:\MailboxList.csv" | ForEach-Object { Get-Recipient -Identity $_.Mailboxes | select Name, Alias, PrimarySmtpAddress }

The second will use the array to output the name, alias and primary email address into a CSV file for each of the users you provided in "MailboxList.csv".

$MyAddresses | Export-Csv "C:\MyEmailAddresses.csv" -NoTypeInformation

Hope this helps.
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
Windows Server 2008

From novice to tech pro — start learning today.