How to Use Get-MailboxDatabaseCopyStatus Command?
Summary: In this post, we’ve explained the parameters that are used in Get-MailboxDatabaseCopyStatus command. We’ve also explained the process to use the Get-MailboxDatabaseCopyStatus command. Also, you’ll find about an Exchange recovery tool that can help you recover Exchange database if anything goes wrong.
Exchange Servers is a business-critical application that requires regular checkups and maintenance to ensure it works smoothly. One may deploy Exchange Server as a standalone or in a Database Availability Group that provides site resilience and automatic failover protection from a database failure.
Get-MailboxDatabaseCopyStatus is one of the several PowerShell commands you can use to keep an eye on the replication health status of databases across all member servers in a Database Availability Group.
You can use the cmdlet to ensure that both active and passive database copies are synchronized. This helps prevent data loss and downtime when disaster strikes or something happens to the main site or server. The PowerShell cmdlet works in Exchange Server 2010, 2013, 2016, and 2019.
Get-MailboxDatabaseCopyStatus Syntax
Below is the syntax of the Get-MailboxDatabaseCopyStatus.
Get-MailboxDatabaseCopyStatus
-Server <MailboxServerIdParameter>
[-Active]
[-DomainController <Fqdn>]
[-ExtendedErrorInfo]
[-UseServerCache]
[<CommonParameters>]
You can use the command to collect information on a specific database in your infrastructure or to get server-wide information.
Let’s explore the parameters of this command.
-Server or -Identity
This parameter will allow you to specify the server’s name from which to retrieve the information. If you want to specify a specific database in a specific server, you need to replace the -server parameter with the -Identity and specify the database/server.
-Active
This parameter will return the information concerning the copy status of the active database.
-DomainController
In this parameter, you need to specify the domain controller you will be using to read or write the data from the Active Directory. You need to specify the fully qualified domain controller (FQDN) of the server, for example, activedirectory01.mydomain.lan.
-UseServerCache
This parameter specifies whether to enable the server-side remote procedure call (RPC) caching status for 5 seconds.
How to Use “Get-MailboxDatabaseCopyStatus” Command?
You need to have the right permissions to run the Get-MailboxDatabaseCopyStatus cmdlet. If you do not know what permissions or role assignments are required, you can run the following command.
Get-ManagementRole -Cmdlet Get-MailboxDatabaseCopyStatus
This command will provide the roles that you need to run the command.
If you need full permissions depending on the parameters, you need to specify the parameters (as given below) and separate each parameter with a comma.
Get-ManagementRole -Cmdlet Get-MailboxDatabaseCopyStatus -CmdLetParamaters extendederrorinfo, useServerCache
After you get the right information, you need to get the permission active for the user to run the cmdlet. For this, open the Exchange Admin Center (EAC), click on Permission, and then click on Admin roles.
It is suggested that you create a new role called GetMailboxCopyStatus and set the permissions needed and assign the users.
Once this is ready, you will be able to run the command.
While running the command, you may encounter many errors. The common ones are:
- Failed
- Crawling
- Status Unknown
- Failed and Suspended
- Content Index failed
One of the things you can do to troubleshoot, before running anything, is to check:
- Any services are down
- There is ample space
- There are no connectivity issues
- There are no connectivity issues with the Active Directory
The next thing to do is run the following commands, depending on the infrastructure.
In a Database Availability Group (DAG), run the following command on the affected indexes to get the failed status.
Get-MailboxDatabase Database Name | Get-MailboxDatabaseCopyStatus | Select Name,*index*
Run the repair command to see if the issue would be fixed.
Update-MailboxDatabasecopy <database>\<server> –sourceserver <server> –catalogonly
Depending on the size of the database and the server’s performance, this procedure can take some time.
In the case of a standalone server, you need to follow the below procedure.
Open command prompt or PowerShell and run the following commands:
Stop-Service MSExchangeFastSearch
Stop-Service HostControllerService
Now, browse to the database location and look for the folder having the name with the long GUID name and delete the folder. This will delete the content index of the database. Once this is done, you need to start the services again.
Start-Service MSExchangeFastSearch
Start-Service HostControllerService
After a few minutes, the folder will be recreated and the content index will be rebuilt.
Conclusion
This is only one example, as each status will need the required procedure to be performed to try to mitigate the issue. If all fails and the active database cannot recover from the issue, the replication between the passive and the active copy (or vice versa) will not happen. If there is a server failure or a failover, you may have to face data loss.
To quickly recover from such situations, you can rely on a certified application that will get you out of a sticky situation and recover your mailbox database with no data loss. Stellar Repair for Exchange is one such application that can open any Exchange Server database file in a healthy, corrupted, or dirty shutdown state. You can browse it and export the data to PST and other file formats. The application also exports the EDB data directly to a live Exchange Server database.