Home » Exchange Server » Using Test-ServiceHealth for Exchange Server Health Checks

Using Test-ServiceHealth for Exchange Server Health Checks

Exchange Server 2010 (and 2007 for that matter) ships with a useful PowerShell cmdlet called Test-ServiceHealth.

As the name suggests, Test-ServiceHealth checks the state of the services that should be running on the Exchange server. One of the best things about this cmdlet is that it checks the services depending on the Exchange server roles that are installed.

So for example, for a Hub Transport server only those services relating to the Hub Transport role will be checked. While for a “typical” Exchange 2010 server the services for the Hub Transport, Client Access, and Mailbox server roles will be checked.

Here is an example of the Test-ServiceHealth results.

As you can see that is a lot of useful information. But whenever possible I like to see just the minimum relevant information for my servers. In the case of Test-ServiceHealth the RequiredServicesRunning result is the thing I am most interested in.

So in this case I could run the following command to see just that information:

Much better.

Now suppose I wanted to run that for all of my Exchange servers. I could do that with the following command:

Interesting, especially the one that failed the test for the Mailbox server role. But in that output I can’t tell which server failed.

Let’s try this instead:

Now we get output that is a little more useful, and tells me which server failed the test.

But it still isn’t quite enough, so let’s wrap this up into a handy script that will do the following:

  • Run Test-SystemHealth for all of the Exchange servers in the organization
  • Tell me which servers passed the test
  • Tell me which servers failed the test, and why

Here is the script code that will perform those steps.

The output from running the script will look something like this.

You can now see at a glance which servers have passed the test, which ones failed, and which services aren’t running for the servers that failed.

Paul is a Microsoft MVP for Office Servers and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul is a co-author of Office 365 for IT Pros and several other books, and is also a Pluralsight author.
Category: Exchange Server

29 comments

  1. Paul says:

    Hi,
    If there I get
    Role : Client Access Server Role
    RequiredServicesRunning : False

    How to make it to true?

    • Paul says:

      Run the command on its own for that server (look at the first example in the article) and it will tell you which required services aren’t running.

  2. art says:

    Hi Paul;
    Thanks for the great script works perfect.
    if you may need to ask my reports has generate only “Hub Transport Server Role Services status is Fail”
    is there something to do? or just ignore?
    thnx

    • Run Test-ServiceHealth on a Hub Transport that is reporting a fail and see what it says.

      My guess is EdgeSync isn’t running, which is harmless if you don’t have Edge servers, but will show as a fail in the report because the test cmdlet considers it a required service.

  3. Krish says:

    HI Paul,

    Thanks for Providing this Wonderful Script. But can you please help me with starting the failed services, after the script shows failed services in red?

    Appreciate your help

    Thanks
    Krish

      • Krish says:

        Yes. But i was asking you, where i can place Start-Service cmdlet in your script.

        So that if the loop checks and shows as “services not running” then it will start the required service automatically.

        It would be a great help , if you can help me with this.

        Thanks

        • You could add it to the section of the script that is running Test-ServiceHealth and processing the results. But I don’t really recommend that. The script can’t tell the difference between a service that is stopped due to an error, and one that is stopped on purpose due to maintenance. I recommend you let the report flag problems to you for manual attention. If you have lots of service failures you need to address the root cause of those.

  4. Gordon says:

    Hello,
    I would like to achieve the following and need some guidance. I would like to run a scheduled task to run the test-servicehealth but only email out to a DL when a required service is in a failed state.
    Could you help to add the necessary code to achieve this?

    Thanking you in advance.

    Gordon

  5. David says:

    Thanks for sharing this. I have a question, how do you check if all the CAS servers are accepting outlook client connections? We have in the past where all the services are running fine and server health is okay but the CAS server just doesn’t accept the Outlook connections.

    Thank you.
    David

Leave a Reply

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