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. Find Paul on Twitter, LinkedIn or Google+, or get in touch for consulting/support engagements.

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!

  3. Do you need to suspend the database copy first before running update-mailboxdatabasecopy?

  4. I have one database that has Content Index State of “unknown”. I cannot run the CatalogOnly as it fails “Seeding of index catalog for database DB1 has failed. Please verify the Microsoft Search (Exchange) and the Host Controller service for Exchange services are running and try again.”

    Yes both services are running and I even tried to restart Microsoft Exchange Search..

    • I have found the Content Index ‘Unknown’ state while Exchange backup job was running (Symantec Backup Exec). Once backup job completed, Content Index state back to ‘Healthy’.
      I am using exchange Server 2013.

  5. HI Paul,

    I am using Exchange Server 2013 CU1 installed on Windows Server 2008 Standard R2.

    Everything was running fine till yesterday but since morning Every user is facing problem while searching email on Outlook Web App. They are getting “An Error Occurred while searching. Please try Again” Error.
    It is also Showing Content index State failed.

    What to do? Please help..

  6. Hi Paul,

    Just curious on what causes these content indexes to fail?
    We have a fairly standard exchange 2010 DAG /CAS setup running on 2008r2 VMs

    I seem to be fixing content index issues weekly…

  7. You can even script it as I’ve done to run every hour or so, and add the failed and suspended status as well:

    Get-MailboxDatabase | Get-MailboxDatabaseCopyStatus | where {$_.Status -eq “FailedandSuspended”}| Resume-MailboxDatabaseCopy
    Get-MailboxDatabase | Get-MailboxDatabaseCopyStatus | where {$_.Status -eq “Suspended”}| Resume-MailboxDatabaseCopy
    Get-MailboxDatabase | Get-MailboxDatabaseCopyStatus | where {$_.Status -eq “Failed”}| Resume-MailboxDatabaseCopy

  8. This will seed the catalog from the active database. If your active server is located at a different location for business continuity planning then your WAN will be heavily used.

  9. Paul,

    I enjoy looking through and using the scripts you have put together to better monitor the health of our DAG. I put this script into production today and very much appreciate what you do!

    Thanks!

  10. Thanks mate, did just what I needed :)

  11. Steve Graham says:

    Worked perfectly. THANK YOU!

  12. Daniel B says:

    We have to run this script many times per day, just to keep our content indexes healthy. Any tips or ideas to look into as to why they are failing so often?

  13. Barry Sherman says:

    I have 8 mailbox database copies that show a “FailedAndSuspended” state. I have a total of 36 databases. All but these 8 are healthy. I have tried your procedures and scripts but these 8 still show as FailedAndSuspended”. Is there anything else to try before opening a ticket with Microsoft?

  14. Phillip says:

    Paul, you are a legend.

    you make us look good!

    Thanks.

  15. Hello,

    Thank you for your advices! I tried your script to fix all the database but nothing happen. It just asks me if i want to apply it to all the database (i say yes for all) and after it does nothing. Do you have an idea?

    Thanks.

Leave a Comment

*

We are an Authorized DigiCert™ SSL Partner.