---
title: List mailboxes in Exchange database with PowerShell
description: "## 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](https://learn.microsoft.com/en-us/powershell/module/exchange/get-mailboxdatabase?view=exchange-ps) cmdlet. Use the **-Status** switch to check the mailbox database mount status. Use the **-IncludePreExchange** switch to…"
url: "https://www.sle.gg/docs/list-mailboxes-in-exchange-database-with-powershell/"
updated: "2026-08-19"
category: Windows
---

# List mailboxes in Exchange database with PowerShell

## 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](https://learn.microsoft.com/en-us/powershell/module/exchange/get-mailboxdatabase?view=exchange-ps) 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](https://www.alitajran.com/mount-database-exchange-with-powershell/). 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
```

**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-Object {$_.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-Object {$_.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.
