How to Get Exchange Mailbox Database Mount Status with PowerShell?

Exchange Server works with databases and from a monitoring or checking point of view, you need to confirm if these databases are online or offline. If the database is mounted, it means that any data in the database file will be accessible by the user. However, if the database is not mounted due to any reason, the mailboxes or public folders residing in it will not be accessible by the user.

Since many Exchange Server Admins make use of the command line for certain works, there is no better contender than PowerShell to manage every aspect of the Exchange Server. In this article, we are going to explore how to use the **Exchange Management Shell (EMS) **to see the status of Exchange Server databases.

Step 1: Open Exchange Management Shell (EMS)

First, you need to open the Exchange Management Shell (EMS). For this, right-click on the EMS icon and then click on Run as Administrator.

Step 2: Run PowerShell Command Get-MailboxDatabase

Once you see that all the modules have been loaded (see below screenshot), you can run the cmdlet.

Here you need to make use of the PowerShell command Get-MailboxDatabase. This will list all Exchange Server databases in your system.

Get-MailboxDatabase

Step 3: Add Parameters

The above cmdlet result doesn’t mention anything regarding the mount status of the databases. Therefore, you need to add some parameters. You can use the | FL parameter. This will load all the information regarding your databases. But still you need to rummage through all the information to see if the database is mounted or not. If you are scripting an email report or trying to get the information to an API on your monitoring system, you will need to filter a lot of data.

This can be easily resolved by specifying the fields that you need to show on the screen. You can use the Format-Table parameter, with the addition of the switch **-Status **in the beginning (see the below example).

Get-MailboxDatabase -Status | Format-Table Name, Server, Mounted

Depending on your needs, you can add other fields to show. The field that you can visualize can be seen, if you run the command with just the | FL parameter.

You can also sort out the information based on various options, like name, date of creation, etc. by using the Sort parameter (see the below example of sort by name).

Get-MailboxDatabase -Status | Sort Name | Format-Table Names, Server, Mounted

Here is an example of sort by mount status.

Get-MailboxDatabase -Status | Sort Name | Format-Table Names, Server, Mounted

To get any databases in your Exchange Server System, if you have an older version of Exchange Server that is coexisting with your new server, you can run the -IncludePreExchange switch at the beginning of the command to list these databases.

Get-MailboxDatabase -IncludePreExchange -Status | Sort Name | Format-Table Names, Server, Mounted

As you can see in the above example, the database called NewDB is not mounted. This means that the mailboxes or resources in the database are not accessible. There could be many reasons why Exchange database is not mounted. Some of these reasons are:

  • -         Human error - an admin might have dismounted the database and forgot to mount it again.
  • -         There was a sudden power loss and the database didn’t shut down properly which might have corrupted a transaction log or damaged the database. This can happen if there was an abrupt shutdown or a hardware failure.
  • -         A malware infection that might have locked crucial files or damaged the files.
  • -         A third-party application, backup software, or antivirus system, which is not compatible with your specific Exchange Server version, might have locked your Exchange Server files. Due to this, the database is not being able to be mounted on Exchange Server. There is also a possibility that the file might have been damaged.
  • -        Issue with licensing. Exchange Server comes in two editions - Standard and Enterprise. The Standard edition will allow you to mount five databases at once while the Enterprise version will allow to mount unlimited databases. So, if you are using Standard edition and have five databases which are mounted and you add sixth database, then this database will not mount.

If such thing happens, the users will not be able to access their data and the business comes to a halt. You might end up restoring from the backup, taking long to restore services, and suffer data loss.