Skip to content

List mailboxes in Exchange database with PowerShell

An excellent way to find out which mailboxes are on an Exchange database is to use PowerShell. With Exchange Management Shell, you can immediately see which mailboxes are located in the database. In this article, you will learn how to list mailboxes in a database.

Get mailbox database name

Before you start, you want to have the mailbox database name. Run Exchange Management Shell as administrator.

Get all mailbox databases with the Get-MailboxDatabase cmdlet. Use the -Status switch to check the mailbox database mount status. Use the -IncludePreExchange switch to get mailbox databases in older Exchange servers.

Note: Remember to mount the mailbox database. Otherwise, you can’t list the mailboxes.

[PS] C:\>Get-MailboxDatabase -Status -IncludePreExchange | Sort Name | Format-Table Name, Server, Mounted

Name Server    Mounted
---- ------    -------
DB01 EX01-2016    True
DB02 EX02-2016    True
DB03 EX01-2016    True
DB04 EX02-2016    True

Read more: Get Exchange mailbox database mount status with PowerShell »

In the next step, we will list all mailboxes in the Exchange database.

List all mailboxes in a database

Find out what mailboxes are in a mailbox database. In this example, we will check mailbox database DB02.

[PS] C:\>Get-Mailbox -Database "DB02" | ft Name, Alias, WindowsEmailAddress, UserPrincipalName

Name            Alias           WindowsEmailAddress       UserPrincipalName
----            -----           -------------------       -----------------
Piers Bower     Piers.Bower     Piers.Bower@exoip.com     Piers.Bower@exoip.com
Richard Grant   Richard.Grant   Richard.Grant@exoip.com   Richard.Grant@exoip.com
Nicholas Murray Nicholas.Murray Nicholas.Murray@exoip.com Nicholas.Murray@exoip.com
Ruth Dickens    Ruth.Dickens    Ruth.Dickens@exoip.com    Ruth.Dickens@exoip.com
Jonathan Fisher Jonathan.Fisher Jonathan.Fisher@exoip.com Jonathan.Fisher@exoip.com
Grace Rees      Grace.Rees      Grace.Rees@exoip.com      Grace.Rees@exoip.com
Patrick Mors    Patrick.Mors    Patrick.Mors@exoip.com    Patrick.Mors@exoip.com

Note The above command doesn’t show if there are archive mailboxes in the mailbox database.

Find out the archive mailboxes in a mailbox database. In this example, we will check mailbox database DB02.

[PS] C:\>Get-Mailbox | Where {$_.ArchiveDatabase -like "DB02"} | ft Name, Alias, WindowsEmailAddress, UserPrincipalName

Name            Alias           WindowsEmailAddress       UserPrincipalName
----            -----           -------------------       -----------------
Hannah Duncan   Hannah.Duncan   Hannah.Duncan@exoip.com   Hannah.Duncan@exoip.com
Hasan Hamza     Hasan.Hamza     Hasan.Hamza@exoip.com     Hasan.Hamza@exoip.com
Jonathan Fisher Jonathan.Fisher Jonathan.Fisher@exoip.com Jonathan.Fisher@exoip.com
Max Gibson      Max.Gibson      Max.Gibson@exoip.com      Max.Gibson@exoip.com
Piers Bower     Piers.Bower     Piers.Bower@exoip.com     Piers.Bower@exoip.com
Richard Grant   Richard.Grant   Richard.Grant@exoip.com   Richard.Grant@exoip.com
Simon Berry     Simon.Berry     Simon.Berry@exoip.com     Simon.Berry@exoip.com

Export all mailboxes in database to CSV file

Export all mailboxes to CSV file in the directory C:\temp. Create a temp folder if you don’t have one.

[PS] C:\>Get-Mailbox -Database "DB02" | select Name, Alias, WindowsEmailAddress, UserPrincipalName | Export-Csv "C:\temp\MailboxesDB02.csv" -NoTypeInformation -Encoding UTF8
[PS] C:\>Get-Mailbox | Where {$_.ArchiveDatabase -like "DB02"} | select Name, Alias, WindowsEmailAddress, UserPrincipalName | Export-Csv "C:\temp\ArchiveMailboxesDB02.csv" -NoTypeInformation -Encoding UTF8

Open the CSV file with Microsoft Excel or another favorite application of your choice.

Keep reading: Determine if a mailbox is on-premises or in Office 365 »

Conclusion

You learned how to list mailboxes in Exchange database with PowerShell. It’s good to know which mailboxes are in a database before you migrate mailboxes, delete a mailbox database, or when there are problems with a database, and you want to see if a mailbox is located in that database. The PowerShell cmdlets are excellent to use.

Did you enjoy this article? You may like Add database copy Exchange Server. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 4 Comments

  1. Is it possible to list all mailboxes in Exchange 2013 of Mailbox type – User
    We are running Hybrid and wanted to see if I can have a list filtered out based on mailbox type

    1. You can run the below command to list user mailboxes on Exchange Server 2013:

      Get-Mailbox -Resultsize Unlimited -RecipientTypeDetails UserMailbox | Where {$_.AdminDisplayVersion -like "*15.0*"} | ft Name, Alias, WindowsEmailAddress, UserPrincipalName

      Exchange Server 2019 = 15.2
      Exchange Server 2016 = 15.1
      Exchange Server 2013 = 15.0

Leave a Reply

Your email address will not be published. Required fields are marked *