How to Defrag Exchange Mailbox Database Via Exchange PowerShell?

Written By Andrew Jackson
Anuraag Singh
Approved By Anuraag Singh
Published On August 24th, 2022
Reading Time 4 Minutes Reading

Space issue in Microsoft Exchange Server is one of the major concern nowadays. As the data in the Exchange mailbox database increases, the size of the database also grows with it. When users remove or deleted the old and irrelevant data from the Exchange database to reduce the space, then also space doesn’t shrink from the database. So, to remove the unused storage or white space from the database, it is necessary to defrag Exchange mailbox database.

To check whether the database needs defragmentation process or not. For that user need to use the Exchange PowerShell Get-MailboxDatabase cmdlet. This will provide the name of the Exchange database, size, AvailableNewMailboxSpace.

Get-MailboxDatabase -Status | ft name,databasesize,availablenewmailboxspace -auto

check mailbox database

Now users can see that the Database “MB-HO-02” has 15.63 GB space and the white space or is 3.696 GB. To make this unused storage usable, user needs to defrag mailbox database Exchange 2016/2013/2010. The defragmentation process improves the performance of the disk and operation of the Exchange Server.

What is the Need to Defrag Exchange Mailbox Database?

In IT organization or any other industry vertical it is important to perform the defragmentation after office hours because it’s a time taking process. According to the database size and Exchange Server performance as well as storage it will take time to defrag the database. The database should be offline/dismounted to execute the defragmentation process.

Another thing that user should note that there should be enough space to defrag mailbox database Exchange 2016/2013/2010. If you are running a shortage of storage in then this could create problem. The new file is created and the data is shifted along with the temporary files.

Note: Use the solution given below to check how much users need the free disk space to defrag the database.

Exchange Database Size – availability of space x 1.1

For Example – Here the size of the database given is 15.63 GB and the available space is 3.696 GB.

15.63 – 6.696 = 8.934
Then, 8.934 x 1.1 = 9.8274

Now, you need 9.8274 GB extra space to perform defragmentation.

Always remember, take the backup of the mailbox database before starting the process. If anything happens in the future then you have an extra file to retrieve your data.

User have two ways through which they can remove the white space:

  1. Create the new Exchange mailbox database and move all EDB mailboxes in that
  2. Perform offline defragmentation on the current database to remove unused space

Pro Tip: If your Exchange database is corrupted/damaged before or during the defrag process, then users can use the SysTools EDB File Repair Tool to remove corruption. This recovery manager for Exchange database software provides Quick and Advance option that easily repair EDB file with no loss of data and after recovery user can export the recovered mailboxes directly to the Live Exchange Server, Office 365, and multiple standard file formats.

Download purchase

How To Defrag An Exchange 2010/2013/2016 Mailbox Database?

Follow the commands given in the below section:

Step 1: Launch the Exchange Management Shell and go to the folder where the database is located

locate database

Step 2: Dismount the Exchange database

dismount the edb

Step 3: Run eseutil /d cmdlet to defrag Exchange mailbox database

perform defragmentation

Step 4: When the defragmentation process is complete, use the mount-database cmdlet to mount the Microsoft Exchange database

Step 5: User can use the Get-MailboxDatabase command and view that all white spaces are gone

white space removed

Note: Now take the complete backup of the mailbox database after using the ESEUTIL command.

Bringing It All Together

Now users have detailed information on how to defrag Exchange mailbox database by using the solution mentioned here. Also, users know above white space, why it need to perform defragmentation and solution to remove white space as well as perform defrag with the help of ESEUTIL command. If users find that the database is unhealthy/damaged/corrupted, then they can use the EDB File Repair tool which removes corruption from offline/dismounted Exchange database file and repair Exchange mailbox in a hassle freeway with no data loss.


By Andrew Jackson

I am SQL DBA and SQL Server blogger too. I like to share about SQL Server and the problems related to it as well as their solution and also I do handle database related user queries, server or database maintenance, database management, etc. I love to share my knowledge with SQL Geeks.