---
title: "Master Exchange Database Management with PowerShell"
description: "Efficiently manage Exchange databases using Get-MailboxDatabase, New-MailboxRepairRequest, and Move-DatabasePath cmdlets. Boost your IT skills today!"
canonical: "https://adamtheautomator.com/get-mailboxdatabase/"
---

# Master Exchange Database Management with PowerShell

> Efficiently manage Exchange databases using Get-MailboxDatabase, New-MailboxRepairRequest, and Move-DatabasePath cmdlets. Boost your IT skills today!

Source: https://adamtheautomator.com/get-mailboxdatabase/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Master Exchange Database Management with PowerShell](https://adamtheautomator.com/wp-content/uploads/2020/02/toimetaja-tolkeburoo-qyt0cPByJjs-unsplash-scaled.jpg)

# Master Exchange Database Management with PowerShell

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)11 February 20204 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Microsoft Exchange](/tag/microsoft-exchange/)[PowerShell](/tag/powershell/)

Table of Contents

*   [Loading Exchange Management PowerShell](#loading-exchange-management-powershell)
*   [Default Locations of EDB Files](#default-locations-of-edb-files)
*   [Finding Mailboxes with Get-MailboxDatabase](#finding-mailboxes-with-get-mailboxdatabase)
*   [Dismounting Exchange Databases with Dismount-Database](#dismounting-exchange-databases-with-dismount-database)
*   [Moving Mailbox Databases with Move-DatabasePath](#moving-mailbox-databases-with-move-databasepath)
*   [Fixing Corrupted Mailboxes with New-MailboxRepairRequest](#fixing-corrupted-mailboxes-with-new-mailboxrepairrequest)
*   [Gluing PowerShell and ESEUTIL Together](#gluing-powershell-and-eseutil-together)
*   [Conclusion](#conclusion)

Any system administrator responsible for a Microsoft Exchange environment will, most likely, at some point need to manage Exchange databases. Instead of using the [Exchange Admin Center](https://docs.microsoft.com/en-us/exchange/exchange-admin-center) admins can use the Get-MailboxDatabase, New-MailboxRepairRequest, and Move-DatabasePath PowerShell cmdlets to make it happen.

During normal operations, you don’t usually need to worry about EDB files. Though they are an integral piece to the functioning of Exchange, day to day operations often don’t involve the databases directly. As stated above, there are a number of scenarios that can call for more direct intervention.

Provided by the Exchange Management Tools, a [PowerShell module](https://adamtheautomator.com/powershell-modules/ "PowerShell module") for managing Exchange is available. Most likely these tools would be installed on your Exchange Server as available in the following [instructions](https://docs.microsoft.com/en-us/Exchange/plan-and-deploy/post-installation-tasks/install-management-tools?view=exchserver-2019).

Let’s dive into some interesting scenarios you might find yourself in.

## Loading Exchange Management PowerShell

> _Note some of these cmdlets are only available for on-premises Exchange._

The generally recommend approached to using the module is via a [PowerShell Remoting](https://adamtheautomator.com/psremoting/ "PowerShell Remoting") session to connect remotely to the Exchange Server and load the Exchange cmdlets as shown below.

```powershell
PS> Set-ExecutionPolicy RemoteSigned
PS> $UserCredential = Get-Credential
PS> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<ServerFQDN>/PowerShell/ -Authentication Kerberos -Credential $UserCredential
PS> Import-PSSession $Session -DisableNameChecking
```

> _Make sure to remove the connection from your PowerShell session when you are done via the command: `Remove-PSSession $Session`._

## Default Locations of EDB Files

Each version of Exchange puts the EDB files in a slightly different location. You’ll see the default locations below. This can come in handy when interacting with these files directly, though with the available PowerShell commands, you may not have to!

*   Exchange Server 2010  
    `C:\Program Files\Microsoft\Exchange Server\V14\Mailbox Database\`
*   Exchange Server 2013  
    `C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database Name\`
*   Exchange Server 2016 & 2019  
    `C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\`

## Finding Mailboxes with Get-MailboxDatabase

Often you just need to know where a given mailbox database is located or any of the many properties available. You can use the `Get-MailboxDatabase` cmdlet to find a lot of useful information about an Exchange database as seen below.

Though there are many properties returned, we are just interested in the `Name`, `EdbFilePath`, and it’s `Mounted` status. To retrieve the actual `mounted` value, use the  `Status` parameter, otherwise no value will be output.

You can see below an example out that the Get-MailboxDatabase cmdlet produces.

```powershell
PS> Get-MailboxDatabase -Name MyExchangeDatabase -Status | Select-Object Name, EdbFilePath, Mounted | Format-List

Name        : MyExchangeDatabase
EdbFilePath : C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database 1000001111.edb
Mounted     : True
--snip--
```

## Dismounting Exchange Databases with Dismount-Database

Now that you have some information on your mailbox database with `Get-MailboxDatabase`, you might choose to dismount the database. To do that, use the  `Dismount-Database` cmdlet.

The default directory where the EDB files are located isn’t ideal. You may have a better performing and more manageable location to move them to. Before you can do that though, you must dismount the database as shown below.

```powershell
PS> Get-MailboxDatabase -Name "MyExchangeDatabase" | Dismount-Database -Confirm:$False
PS> Get-MailboxDatabase -Name "MyExchangeDatabase" -Status | Select-Object Name, Mounted | Format-List

Name    : MyExchangeDatabase
Mounted : False
--snip--
```

## Moving Mailbox Databases with Move-DatabasePath

Since you have dismounted the database, now move the mailbox database to a new location.  This is done using the appropriately named, `Move-DatabasePath` cmdlet.

Wait! What if ran `Get-Mailboxdatabase` and found that you had _circular logging_ turned on? According to the [best practices](https://docs.microsoft.com/en-us/exchange/high-availability/manage-ha/move-db-copies?view=exchserver-2019) for moving database files, this needs to be turned off. To do this, use the `Set-MailboxDatabase` cmdlet.

```powershell
PS> Set-MailboxDatabase -Name MyExchangeDatabase -CircularLoggingEnabled:$False
```

Depending on our environment there may be some extra steps to take before doing that. Notably you may need to remove existing mailbox database copies. Mailbox database copies are copies of a database that are distributed and replicated among your Exchange servers. Don’t worry, even though we are removing them here, we are going to add them back!

```powershell
PS> Remove-MailboxDatabaseCopy -Identity MyExchangeDatabase -Confirm:$False
```

You should now be able to move the database to the new location. Running `Move-DatabasePath` will actually relocate the database files to a new path, provided the database is dismounted.

```powershell
PS> Move-DatabasePath -Identity MyExchangeDatabase -EdbFilePath C:\EDB\MyExchangeDatabase.edb
```

Success! The databases are moved, now add back the database copies and also turn _circular logging_ back on as shown below.

```powershell
PS> Add-MailboxDatabaseCopy -Identity MyExchangeDatabase
PS> Set-MailboxDatabase -Name MyExchangeDatabase -CircularLoggingEnabled:$True
```

## Fixing Corrupted Mailboxes with New-MailboxRepairRequest

After the database move, perhaps you’d like to ensure there aren’t any corrupted mailboxes on the database. Conveniently there is a command for that called `New-MailboxRepairRequest`. This command can be run on an individual mailbox or, if run without parameters ,on all mailboxes within a given database as shown below.

```powershell
PS> New-MailboxRepairRequest -Database MyExchangeDatabase
```

> _Important! After you begin the repair request, you must dismount the database to stop the process. Additionally, only the mailbox being repaired is inaccessible, all others remain accessible during the database repair._

## Gluing PowerShell and ESEUTIL Together

One of the powerful capabilities with PowerShell is the ability to glue many different tools together. A go-to utility for many Exchange Administrators is `eseutil.exe`.

Perhaps you’d like to defragment an EDB file. Defragmentation can be done via `eseutil`. An example of this is the following script that illustrates combining PowerShell with standard shell utilities.

```powershell
PS> Set-Location -Path (Split-Path (Get-MailboxDatabase -Name MyExchangeDatabase).EdbFilePath)
PS> Dismount-Database -Name MyExchangeDatabase
PS> eseutil /d MyExchangeDatabase.edb /
PS> Mount-Database -Name MyExchangeDatabase
```

> Note that when you start defragmentation on a database, your users cannot access any mailboxes stored in that database. Additionally, you will need about 110 percent the size of the database on disk to perform the defragmentation.

## Conclusion

Although you can do many of the operations via the Exchange Admin Center, a best practice to administration is that of automation and repeatability. By leveraging PowerShell, you can limit common admin repetitions through automating many common scenarios, ultimately saving time and preventing headaches!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fget-mailboxdatabase%2F&text=Master%20Exchange%20Database%20Management%20with%20PowerShell)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fget-mailboxdatabase%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fget-mailboxdatabase%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2020/07/New-Exchange-Online-V2-PowerShell-Module.png)

### [Connect to Exchange Online PowerShell with EXO V2 Module](/exchange-online-v2/)

Learn how to connect to Exchange Online via PowerShell using the EXO V2 module for unattended, app-only authentication.

![](https://adamtheautomator.com/wp-content/uploads/publisher/2e05d9c85b2b81feb24af1f04a889143/3eab14af9dabf46fbd333914ce6ccf46f84117d2394d3e7218c186cd249bb7e2.webp)

### [PowerShell or Power Automate: Stop Automation Mistakes](/powershell-vs-power-automate/)

Score six factors to choose between PowerShell and Power Automate: target system, complexity, data volume, team skills, cost, governance.

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
