Exchange 2013 Powershell Help

Platform: Exchange 2013 Powershell


I would like to use Exchange Powershell to give me a list of all people that are in an Exchange Database in a specific format.  
For instance, I would like the command to show me "Here are the employees that are in Database1".  Here are the 2 requests:
1.  It needs to be exported to a CSV file
2.  It needs to show their email address, first name, last name, username, and display name.  

Any help would be greatly appreciated!  Thank you.
Who is Participating?
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.

timgreen7077Exchange EngineerCommented:
You can run the following:

Get-Mailbox -Database "database" -ResultSize unlimited | select name, displayname, alias, PrimarySmtpAddress, database | Export-Csv c:\temp\results.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
MASEE Solution Guide - Technical Dept HeadCommented:
HI zito2000,
Get-Mailbox output does not have properties called  firstname & lastname. You have to try with get-recipient. Please try below.
Get-Recipient | select primarysmtpaddress,firstname,lastname,alias,displayname | Export-Csv c:\temp\mailboxdetails.csv

Open in new window

timgreen7077Exchange EngineerCommented:
Get-mailbox will display user first and last name unless your are talking about first name column and last name column. The cmdlets i provide will satisfy the author's request, including searching specific DB.
SolarWinds® Network Configuration Manager (NCM)

SolarWinds® Network Configuration Manager brings structure and peace of mind to configuration management. Bulk config deployment, automatic backups, change detection, vulnerability assessments, and config change templates reduce the time needed for repetitive tasks.

zito2000Author Commented:
Both of these were extremely helpful, thank you both!!
I ended up using MAS' command because of the first name/last name separation, but TimGreen's worked like a charm as well to break up by database.
MASEE Solution Guide - Technical Dept HeadCommented:
Glad to know Timgreen's command helped.

Thanks for being on-board.
I didnt mean your command is wrong. We both commented the same time.
Ultimately asker's requirement is met. This is the objective here.
timgreen7077Exchange EngineerCommented:
Agreed and thank you also.
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.