This post is also available in: Polish
When we want to check DAG (Database Availability Groups) status we should use two below powershell CMDlet’s:
Get-MailboxDatabaseCopyStatus will check and show status of all mailbox databases in all the DAG’s in Microsoft Exchange environment.
Test-ReplicationHealth check all aspects of replication and replay, or to provide status for a specific Mailbox server in a database availability group (DAG).
To check copy status of all mailbox databases we should use:
(Get-DatabaseAvailabilityGroup) | ForEach {$_.Servers | ForEach {Get-MailboxDatabaseCopyStatus -Server $_}}
As a result we will get mailbox databases copy status, CopyQueueLength, ReplayQueueLength, LastInspectedLogTime and ContentIndexState.
If ContentIndexState is Failed then we need to run Update-MailboxDatabaseCopy for those mailbox database like below:
Update-MailboxDatabaseCopy "Database\Server02" -CatalogOnly
Next we can run test for all servers in DAG like below:
(Get-DatabaseAvailabilityGroup) | ForEach {$_.Servers | ForEach {Test-ReplicationHealth -Server $_}}
As a result we will receive server name, name of test (Check) and result of test. All results should be Passed.