PowerShell Tip: Fix All Failed Exchange Database Content Indexes

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.

About Paul Cunningham

Paul is a Microsoft Exchange Server MVP and publisher of Exchange Server Pro. He also holds several Microsoft certifications including for Exchange Server 2007, 2010 and 2013. Connect with Paul on Twitter and Google+.

Comments

  1. Keith K. says:

    Worked like a charm, thanks for the script Paul! :-)

  2. Thanks for the tip Paul, this tip along with a couple of others provided by you have really helped us out!

Leave a Comment

*

We are an Authorized DigiCert™ SSL Partner.
Loading...

Still running Exchange 2003? Time to get moving and start your upgrade. Find out how - Click Here