Exchange Server stores mailboxes in Exchange Server database file, with the extension .edb. When users or administrators make changes to the mailboxes or database, such as send/receive messages, the Exchange Server records these activities in transaction logs that are later committed to the Exchange database file (.edb). This helps increase the performance and keep the database healthy.
However, if the transaction logs get corrupt, deleted or the server shuts down before transaction logs are committed to the database file, it may lead to inconsistencies and cause Exchange Server database corruption. This may occur due to reasons, such as:
- Server crash
- Sudden/abrupt server shutdown due to power failure
- Hardware or software failure
- Virus or malware intrusion
- Human error
When a user mailbox is corrupted or damaged, users can notice some obvious signs in their mailbox, such as:
- Email folders with incorrect item numbers
- Search results not showing emails or correct results
- Missing mail items from the folders
- Can’t access the mailbox or mail items
In such a case, you can use the New-MailboxRepairRequest PowerShell cmdlet to run mailbox repair requests and fix corrupt user mailboxes. You may also use EseUtil to try to fix issues with the entire mailbox database.
Below, we are going to discuss how to use the PowerShell cmdlets and EseUtil utility to repair corrupt mailboxes and database (EDB) in Exchange 2010 SP1 and later versions.
Repair Corrupt Exchange Mailboxes using New-MailboxRepairRequest Cmdlet
The New-MailboxRepairRequest cmdlet was introduced in Exchange 2010 SP1 and is available in all the later versions. If you are facing mailbox corruption, you can use this cmdlet to fix mailbox corruption. However, if you are running an older Exchange Server, you will have to use the EseUtil commands.
If you suspect Exchange mailbox or database corruption, you can run the mailbox repair request using the New-MailboxRepairRequest cmdlet in the following mailbox corruption types:
- FolderView – Fixes incorrect content in email folders
- ProvisionedFolder – Fixes Provisioned Folders with incorrect parent folders
- SearchFolder – Fixes search folder corruption
- AggregateCounts – Fixes incorrect item numbers reflecting in the mailbox folders
To run a mailbox repair request in the detect mode for FolderView corruption type, execute the following PowerShell cmdlet in the Exchange Management Shell (EMS).
New-MailboxRepairRequest -Mailbox <MAILBOXNAME> -CorruptionType FolderView
This cmdlet detects and repairs folder view and fixes discrepancies with the user mailbox that belongs to the user.
You can change the –CorruptionType parameter value to create repair requests for fixing ProvisionedFolder, SearchFolder, and AggregateCounts.
New-MailboxRepairRequest -Mailbox <MAILBOXNAME> -CorruptionType ProvisionedFolder,SearchFolder,AggregateCounts
You may also run the repair request on the database to repair all mailboxes with the following command:
New-MailboxRepairRequest -Database <DATABASENAME> -CorruptionType AggregateCounts,ProvisionedFolder,SearchFolder,FolderView
How to check if this worked?
You can check the progress and monitor the repair requests by using the Get-MailboxRepairRequest cmdlet.
Get-MailboxRepairRequest –Mailbox <MAILBOXNAME> | Format-List
For a summary view, execute the following PowerShell cmdlet:
Get-MailboxRepairRequest –Mailbox <MAILBOXNAME> | Fl Tasks,Corruption*
To view the progress and status of all the mailboxes, execute the following cmdlet:
Get-MailboxDatabase | Get-MailboxRepairRequest | Format-Table Identity
Fix Exchange Mailbox Corruption using EseUtil
EseUtil or Extensible Storage Engine Utility is a command line-based tool to fix corrupt Exchange Server mailbox databases, defragment, and check integrity. The utility is available in all Exchange Server versions starting from Exchange 4.0 and is located in the C:\Program Files\Microsoft\Exchange Server\VXX\Bin\.
EseUtil comes in handy when the mailbox database dismounts and goes offline due to inconsistencies or corruption.
The steps to repair corrupt database using EseUtil are as follows:
- Run the following EseUtil command to check the database status:
EseUtil /mh <DatabaseName>
- Check the output. If it displays ‘Dirty Shutdown’, you can attempt Soft Recovery on the database using the following command:
EseUtil /r <log Prefix> /l <LogFolderPath> /d <DatabasePath>
EseUtil /r E00 /l "C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\MBXDB001" /d "C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\MBXDB001"
- This will try to fix small corruptions in the database/logs. Once the command is executed successfully, check the database status using EseUtil /mh <DatabaseName>.
- If the database is in Clean Shutdown state, you can mount the database using the following command:
Mount-MailboxDatabase –identity <DatabaseName>
- After mounting the database, check and repair the mailbox corruption using the New-MailboxRepairRequest cmdlet (as discussed above).
However, if the database is still in Dirty Shutdown state, you may attempt Hard Recovery using the EseUtil command. However, Hard Recovery restores the database by purging any data in the database, which is deemed as corrupted or irrecoverable. This can lead to missing mailboxes and permanent data loss situations.
Instead, you can use an Exchange recovery software, such as Stellar Repair for Exchange, to recover the database and restore the mailboxes with complete integrity and accuracy.
The software can help you repair and restore all mailboxes from the Exchange Server database to a new or existing healthy database on a live Exchange Server. You may also save the repaired and recovered mailboxes in Outlook PST format and then import them manually.
Mailbox corruption is common and may occur due to several reasons, as discussed in this article. You can identify mailbox corruption by observing signs, such as missing mail items, incorrect number of mail items in folders, wrong or no search results, etc. Sometimes the mailbox may also become inaccessible due to corruption and Outlook may fail to connect to the mailbox on the server. You can use the New-MailboxRepairRequest cmdlet to run mailbox repair requests and fix the mailbox corruption in Microsoft Exchange Server 2010 SP1 and later. For earlier versions, you can use the EseUtil to troubleshoot database corruption. You may also use an Exchange recovery software, discussed in this article, to repair and recover corrupt mailboxes with complete integrity. The software supports Exchange Server 2019, 2016, 2013, 2010, 2007, 2003, and 5.5.