How to Use Get-MailboxDatabase Cmdlet?

Microsoft introduced the Exchange Server PowerShell (Exchange Management Shell) with Exchange 2010 SP1 release. It is a powerful command-line-based utility enabling the administrators to perform various administrative tasks. Using the Exchange Management Shell (EMS) cmdlets, administrators can analyze and manage mailboxes, databases, and various other aspects of Exchange Server.

You can use the Get-MailboxDatabase cmdlet to gather information about the database(s) on a particular server or multiple servers in your organization. You may also use the cmdlet to retrieve information from a specific database in your organization that may help you analyze the database, figure out the issues, and fix them accordingly.

In this article, you will learn how and when to use the Get-MailboxDatabase cmdlet in an on-premises Exchange Server using various switches and parameters to retrieve the required information and analyze the mailbox database.

Using Get-MailboxDatabase Cmdlet in Exchange Server

To use the Get-MailboxDatabase cmdlet, the user must have the required roles and permissions. To know and assign the required roles and permissions, follow these steps:

  • Open Exchange Management Shell and execute the following commands to list the required roles and permission to run the Get-MailboxDatabase

$Perms = Get-ManagementRole -Cmdlet Get-MailboxDatabase

$Perms | foreach {Get-ManagementRoleAssignment -Role $_.Name -Delegating $false | Format-Table -Auto Role,RoleAssigneeType,RoleAssigneeName}

Once the roles and permissions are assigned, you can run the Get-MailboxDatabase cmdlet in Exchange Management Shell without any parameter. However, running the cmdlet with no parameter will display information about all mailbox databases in your Exchange Server or organization.

To retrieve information about all the databases on a particular server in your Exchange organization, you must use the -server parameter and specify the mailbox server name.

For instance,

Get-MailboxDatabase –server Exchange19 | Format-List

Get-MailboxDatabase server cmdlet

Get-MailboxDatabase -server Exchange19 | Format-list Name,Mounted,GUID,DistinguishedName

get mailbox database server exchange19 format list name mounted guid distinguishedname

Similarly, you can use the –identity parameter to get detailed or specific information about a particular database. For instance,

Get-MailboxDatabase –Identity MBXDB01 | Format-List

get-MailboxDatabase Identity

Get-MailboxDatabase –Identity MBXDB01 | Format-Table Name,GUID,DistinguishedName

Get Mailbox Database Identity Name-GUID Distinguished Name

Get-MailboxDatabase –Identity MBXDB01 | Format-list Name,GUID,DistinguishedName

name guid distinguished name get mailbox database identity format list

Using the -Status switch, you can gather all or specific information related to the database on a particular server, available free space in the database root, and information about the backup progress, mount status, and online maintenance progress.

For instance,

Get-MailboxDatabase –Status| Format-list

get mailbox database status format list

Get-MailboxDatabase –Status| ft name,server,BackupInProgress,Mounted,OnlineMaintenanceInProgress

get mailbox database name server backup

Similarly, you can use various parameters to fetch specific details or values, such as:

  • CircularLoggingEnabled
  • EdbFilePath
  • DatabaseCopies
  • MountedOnServer
  • DeletedItemRetention
  • AvailabileNewMailboxSpace
  • LogFilePrefix
  • IsMailboxDatabase
  • IsPublicFolderDatabase
  • Identity
  • IndexEnabled
  • IssueWarningQuota

And many more.

When to Use Get-MailboxDatabase Cmdlet?

The Get-MailboxDatabase cmdlet is used to check the database status and information. The information received by executing the command allows you to check whether the database is mounted and working or if there’s an issue. You can then take appropriate actions to modify, repair, or manage the database using the Exchange Admin Center (EAC) or other PowerShell cmdlets in EMS.

To repair a dismounted database in the Dirty Shutdown state or database that doesn’t mount, you can use the Extensible Storage Engine Utility (EseUtil) to repair the corrupt database, bring it to a clean shutdown or mountable state, and then mount the database using the EAC or Mount-Database cmdlet.

You can use the Eseutil /r command to run ‘Soft Recovery’, which replays the transaction logs on the inconsistent or damaged database. This commits the uncommitted changes to the database and may bring the database to the Clean Shutdown state. To verify the database status, you can use the EseUtil/mh databasepathwithname.edb /databasepathwithname.edb command in Command Prompt or EMS on your Exchange Server.

For instance,

eseutil /mh C:\mbx01\mbx01.edb

eseutil mh command dirty shutdown

If the database is still in Dirty Shutdown state, you may proceed with ‘Hard Recovery’ using the EseUtil /p command. However, this may cause data loss. Thus, proceed at your own risk.

hard recovery eseutil warning

To avoid data loss and restore all mailboxes from the damaged database with complete integrity, you can use an Exchange recovery software, such as Stellar Repair for Exchange. The software can help you repair severely damaged or corrupt databases and save the mailboxes as individual PSTs. You may also export the mailboxes directly to Office 365 tenant or live Exchange Server.

Once repaired and mounted, use the Get-MailboxDatabase –Identity databasename | fl /databasename command to check the database details. To view specific information, you may also use the following command:

Get-MailboxDatabase –Status | ft name, server, mounted

Check database mount status

Also, it is recommended that you move mailboxes from a repaired database to a new or existing healthy database and avoid using the repaired database.

Conclusion

In this article, you have learned how to use the Get-MailboxDatabase PowerShell cmdlet to retrieve information related to a database or databases on your Exchange Server. The cmdlet helps administrators analyze the database status, detect problems, and take appropriate actions to resolve various issues. You can use the cmdlet to retrieve detailed information related to a database or specific information by using various parameters. Further, if you need to repair the database, you can use the EseUtil commands or the Exchange recovery software. The software can extract all mailboxes from the corrupt database and restore them to a healthy database on your live Exchange Server directly.



Was this article helpful?
About The Author
author image
Ravi Singh linkdin Icon

Senior Writer at Stellar®. He is an expert Tech Explainer.

Table of Contents

WHY STELLAR® IS GLOBAL LEADER

Why Choose Stellar?
  • 0M+

    Customers

  • 0+

    Years of Excellence

  • 0+

    R&D Engineers

  • 0+

    Countries

  • 0+

    PARTNERS

  • 0+

    Awards Received