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.

Note: for failed content indexes on servers that are not DAG members refer to this article instead.

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

    Paul, we are have a 2 DAG setup. For some reason the active node got dismounted and passive node is in Failed and Suspended state. I’ve manually removed all transact logs from both databases and copied .edb file from dismounted node to the passive node however I can’t get database mounted :( Can you please help ?? I’ve been working on it all day and ready to pull my hair out

  14. Igor P says

    We have 2 Exchange servers in our primary site and 2 Exchange servers in our DR site. When I run “Get-MailboxDatabaseCopyStatus” command everything showing up as “Healthy” except “ContentIndexState” on servers in DR site for 1 database showing ups as “Crawling” and it never switches to “Healthy” state. I completely rebuild Content Index directory on the server in primary site and did the same thing on the server in the DR site, but it still showing up as “Crawling.” This state prevents database failover. Is there anything can be done? I wasn’t able to find a way to monitor “Crawling” process, so I’m not sure if it is actually going but slow or just hanging. I tried enabling perfmon to see if there are any activity under “Full Crawl Mode Status” but I get nothing there either. Any help would be greatly appreciated.

  15. Benito 34 says

    Paul, in our updated Outlook 2010 we constantly get complaints that our “Search inbox” is not working, and we have to log into our 2 Exchange servers to restart ” Microsoft Exchange Index” and this usually takes time to replicate. any assistance would be greatly appreciated.

  16. John Loi says

    Hi, I moved a database to another drive on the same server and accidentally renamed whilst changing the path. Once the move was completed a copy of the database with the new name was created however the original database still remained. When I check the database properties the path is still pointing to the original location. My problem is now I cannot mount the database. I am novice to exchange and any help would be very much appreciated.

Leave a Reply

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