One of the issues that my Get-DAGHealth.ps1 script alerts for is failed content indexes on database copies in a database availability group.
Failed content indexes can easily go unnoticed when everything else is working fine however they will eventually begin to cause problems for you, for example by preventing database switchovers.
Fixing a single failed content index is easy, but if there are multiple failed indexes you can speed things up a little by fixing them all with a single PowerShell command.
To demonstrate, here is the Exchange Management Shell command for using Get-MailboxDatabaseCopyStatus to display all database copies that have a content index in a failed state.
[PS] C:\>Get-MailboxDatabaseCopyStatus * | where {$_.ContentIndexState -eq "Failed"}
Name Status CopyQueue ReplayQueue LastInspectedLogTime ContentIndex
Length Length State
---- ------ --------- ----------- -------------------- ------------
Mailbox Database 1\HO-EX2010-MB1 Healthy 0 0 22/02/2013 10:43:26 AM Failed
Mailbox Database 2\HO-EX2010-MB1 Healthy 0 0 22/02/2013 10:41:36 AM Failed
So all we need to do is pipe the output of that command into the Update-MailboxDatabaseCopy cmdlet with the -CatalogOnly switch.
[PS] C:\>Get-MailboxDatabaseCopyStatus * | where {$_.ContentIndexState -eq "Failed"} | Update-MailboxDatabaseCopy -CatalogOnly
Wait for that process to complete, then re-run the first command again. If no results are returned this time then there are no more failed content indexes.




Worked like a charm, thanks for the script Paul!
Thanks for the tip Paul, this tip along with a couple of others provided by you have really helped us out!