Exchange 2010 – Exchange Management Shell (EMS) Export a list of all users in a specific Mailbox Database to CSV

 

This is very easy using EMS.

WHAT WILL OUR CSV FILE LOOK LIKE:
Display Name – Is exactly what it implies
Server Name – What server the users mailbox currently resides on
Primary Email Address
Email Addresses – All smtp aliases currently associated with the user’s account

1. CSV File Format

All you will need to change in the script below is the DATABASENAME to your mailbox database name and you can change the output file name from users-in-DATABASENAME.csv to whatever you want.

Code is as follow:

Get-Mailbox -Database “DATABASENAME” -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses | Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Export-CSV c:\users-in-DATABASENAME.csv -NoTypeInformation

If this was helpful please click on the STAR rating and give me a thumbs up 🙂

Have a good one!! Cheers!