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.

Comments

  1. SimonF says

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

  2. David says

    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..

    • Nazeef says

      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.

  3. Manoj says

    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..

  4. Deni says

    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…

  5. says

    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

  6. Toan says

    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.

  7. Ken says

    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!

  8. 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?

  9. 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?

  10. Fabian says

    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.

  11. Chris Darrow says

    I tried your steps but I get an error on all my DBs:

    Database ‘Management\VEXCH01′ has only one copy. This task is supported only for databases that have more than one copy.

  12. Anil says

    Do I need to run this command in content Indexing failed server or I can rum from any mailbox server ? kindly suggest.

  13. Anil says

    Hello,

    Do I need to run this command in content Indexing failed server or I can run from any mailbox server ? kindly suggest. Currently content Indexing failed in my DR server.

Leave a Reply

Your email address will not be published. Required fields are marked *