Your Exchange Server infrastructure needs to stay up to date because of vulnerabilities, new features,…
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.
Table of contents
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 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.
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
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
Export all mailboxes in a database to CSV file
Export 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
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 »
In this article, 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 or when there are problems on a database, and you want to see if a mailbox is located on that database. The PowerShell cmdlets are excellent to use.
Did you enjoy this article? You may like Add database copy Exchange 2016. Don’t forget to follow us and share this article.