A new version of Test-ExchangeServerHealth.ps1 is now available for download. This update contains the following fixes and improvements:

  • Shadow redundancy queues are no longer included in the transport queue size
  • Recovery DBs are now excluded from all Get-MailboxDatabase commands, to avoid issues running tests against them
  • Content index state of “Autosuspended” (introduced in recent CUs) is now catered for as a healthy state
  • Incorrect reporting of Test-ReplicationHealth results for different versions has been fixed
  • Various formatting, readability and other minor issues fixed

You can download the script from the TechNet Script Gallery. For more information on how to use Test-ExchangeServerHealth.ps1, please refer to this blog post.

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Comments

  1. Manoj Kumar

    Hello Paul

    Does this script for Exchange 2019 server as well?

    Manoj

  2. Bikerpete

    For the non-english Exchange environment users:
    If you receive errors at “Mail Flow Test”, you should do the test manually and check the value of the positive result.
    Around line 1202 you will find
    if ($testmailflowresult -eq “Erfolgreich” -or $testmailflowresult -eq $success)
    As you see, it checks the value and on a German system, it is Erfolgreich (which means Success).

    Keep up the great work,
    Pete

    1. Lee

      Recently, the script failed with this error as it can’t convert database value, please help

      MAPI connectivity: Cannot process argument transformation on parameter ‘Database’. Cannot convert value “DB02” to type “Microsoft.Exchange.Configuration.Tasks.DatabaseIdParameter. Hashtable-to-Object conversion is not supported in restricted language or a Data section.”

      1. Dennison

        Hi Lee,
        You can try change following
        Test-Mapiconnectivity -Database $db.Identity -PerconnectionTimeout $mapitimeout
        to
        Test-Mapiconnectivity -Database $db.Name -PerconnectionTimeout $mapitimeout

        In my environment it works.

  3. Bob

    This is the best script I have. It’s been great forever. Can you add secure mail options? My preferred SMTP mailer requires a username and password. I can’t work out how to add this myself to the script (apologies if it’s already there, but I couldn’t see it).

    Thanks again.

  4. Muthu

    Thanks for sharing the script. The script is working perfectly.
    But one of our exchange server’s mailflow result displaying result as failed while we using this script but actually the server do not have such issue.

    Shall we know why the report is detecting such failure when the problem is not exist and how can we fixed it ?

    Appreciate your response

  5. Fred

    Hi Paul, many thanks for this very useful health check script, just had a quick question regarding the exclusion file.
    I have no issue listed servers that I want to exclude, however I have a challenge listing some databases to exclude, i.e I have some restore DBs which are unmounted and want to exclude them from a couple of servers but listing the database names don’t seem to work.
    Could you advise what is the correct format to allow this to work.

    Thanks, Fred

  6. Duncan

    Hello Paul,

    Since we have updated to Exchange 2016 CU11, we receive an error while the script is initializing.

    WARNING: Cannot load Windows PowerShell snap-in Microsoft.Exchange.Management.PowerShell.E2010 because of the following error: Unable to load DLL ‘dsaccessperf.dll’: The specified module could not be found. (Exception from HR
    ESULT: 0x8007007E)

    Best regards,

    Duncan

  7. Tung.Hoang Thanh

    Hi Mr Paul

    I ran scripts on HUB/CAS server, i had problem as below:

    You must provide a value for this property.
    + CategoryInfo : NotSpecified: (0:Int32) [Get-MailboxDatabase], DataValidationException
    + FullyQualifiedErrorId : 8FE08272,Microsoft.Exchange.Management.SystemConfigurationTasks.GetMailboxDatabase

    You must provide a value for this property.
    + CategoryInfo : NotSpecified: (0:Int32) [Get-MailboxDatabase], DataValidationException
    + FullyQualifiedErrorId : 8FE08272,Microsoft.Exchange.Management.SystemConfigurationTasks.GetMailboxDatabase

  8. Gavin

    Script is great, however when checking the uptime there is an access denied error. Any idea why this would happen? The account running the script has Admin rights on each Exchange Server.

  9. Steven Collins

    Is there an easy way to have the report show content index status for a server that doesn’t have a DAG? We have 3 databases not in a DAG

  10. Rennex Callaghan

    Hey Paul,

    Thank you for all the great work! What is the frequency that we should be running this scripts. How often would you recommend ?

    Rennex

  11. rasheedah muhammad

    Skipping CA checks.

    Hi is it possible to add this line on the script

    $sessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck

    We are getting CN errors due to server name.

  12. SANKARASUBRAMAN PARAMESWARAN

    Im having the same issue. I don’t want to use the server name and liked to use the common name. any suggestions

  13. Gambled

    Awesome anf very useful script! We disable UM services in our environment. As a result, that service is reported as “Fail” with red box. Any way to get the script to bypass testing the UM service, or at least make it say “n/a” for that particular service?

    1. Avatar photo

      Is there anything you gain by disabling the service?

      If you want to leave it disabled, then you will need to customize the script to work around that. The script relies on the Test-ServiceHealth cmdlet for that part, so you would need to write some customizations that check which services aren’t running, and if it’s a service you have disabled change the status from failed to pass.

  14. Lance Davidson

    I had the same issue with the Mail Flow test fails. Even after changing the Internal URL for PowerShell to use the server name.

    I needed to also change the internal PowerShell name to be HTTP not HTTPS.

    Worked for me 🙂

    1. Noel Flores

      Hello Lance I’m having the same error mine is already in the internal URL and internal PowerShell in Virtual directories are already in HTTP.

      Can you please advice where did you change this?

      Thanks

  15. Wladinho

    Hi Paul,

    When I tried to run your script on Exchange 2016 CU8, I got error only on mailflow. On Exchange 2013 (same server setup) this script works perfectly.

    Mail flow test: WARNING: Connecting to remote server email.xxxxx.com failed with the following error message : WinRM can not process the request. The following error occurred while using Kerberos authentication: Cannot find the computer email.xxxxx.com.
    Verify that the computer exists on the network and that the name provided is spelled correctly. For more information, see the about_Remote_Troubleshooting Help topic.
    WARNING: Cannot validate argument on parameter ‘Session’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
    Remove-PSSession : Cannot validate argument on parameter ‘Id’. The argument is null. Provide a valid value for the argument, and then try running the command again.
    At C:\Scripts\Test-ExchangeServerHealth.ps1:452 char:22
    + Remove-PSSession $session.Id
    + ~~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Remove-PSSession], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.RemovePSSessionCommand

    Fail

    1. Wladinho

      Solved 🙂

      Internal URL for PowerShell virtual directory was configured with public name.

      Now everything is fine.

      Thanks 🙂

      1. Josh Houston

        I’m having the same issue. Can you explain what you changed? I am new to exchange and have looked at the virtual directories and the external and internal url’s are configured.

        1. Rhys Evans

          Just to update this, I just had the same problem in a Exchange 2016 DAG environment and fixed it by doing the following:

          Go to “https://mailserver.domain.com/ecp”
          Click on Servers, Virtual Directories and look down the list for powershell.
          both my servers had public IP as internal address.

          So mine was “mail.domain.com” i changed it to “exch01.sub.domain.com” and “exch02.sub.domain.com”

          Now the script runs fine and passes.

          1. ajnabig

            Changing internal URL of PowerShell directory to server name resolved the issue.

  16. Özer YÜMSEK

    Hello Paul,

    We are running the script and send mail it says “Client Access Server Role Services” and “Hub Transport Server Role Services” fails. We are running script on Exchange management shell it doesnt give an error.
    Client Access Server Role Services: Pass
    Hub Transport Server Role Services: Pass

    What can cause this error.

    Exchange server version is 2010 SP3 UR 18

    Thank you very much / Regards

      1. ozer yumsek

        Hello Paul
        Thank you for reply.
        Yes they are english servers.
        Regards

        1. Avatar photo

          The script uses the Test-ServiceHealth cmdlet for those checks. You can run that cmdlet yourself to see if it reports a problem. Without seeing your log file from running the script I can only guess what might be going wrong.

    1. Roger Eastman

      I have the same problem with Exchange 2016 CU 14. I have 2 severs and the server that runs the script reports fine but the other server shows Could not test service health for CS, HUB, MB and UM services. It is also vice versa the other direction. Is there something special the script is expecting for remote servers? I have been using your script on my Exchange 2010 servers with no problems for years. thx.

  17. Curt Verwolf

    Paul,

    Hope all is well with you my friend! Maybe you can help one of my clients with a problem they are seeing:

    We are seeing the following error when the mailflow test runs against 2016 DAG members…

    Mail flow test: WARNING: Connecting to remote server EXCH2016.Contoso.com failed with the following error message :
    The WinRM client cannot process the request because the server name cannot be resolved. For more information, see the
    about_Remote_Troubleshooting Help topic.
    WARNING: Cannot validate argument on parameter ‘Session’. The argument is null or empty. Provide an argument that is n
    ot null or empty, and then try the command again.
    Remove-PSSession : Cannot validate argument on parameter ‘Id’. The argument is null. Provide a valid value for the
    argument, and then try running the command again.
    At C:\Enpointe\Test-ExchangeServerHealth.ps1:426 char:19
    + Remove-PSSession $session.Id
    + ~~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Remove-PSSession], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.RemovePSSessionCommand

    Fail

    Any help would be greatly appreciated…:)

  18. Mario

    Hey Paul, Thank you for the script.

    I have Exchange 2010 and 2016 currently running. Mail Flow Tests Fail on Exchange 2016 side but not 2010. I open up EMS and run “Test-MailFlow EXCH2016” and the mailflowresult comes back as Success. Any Suggestions?

    1. Özer YÜMSEK

      Hello Paul,

      We are running the script and send mail it says “Client Access Server Role Services” and “Hub Transport Server Role Services” fails. We are running script on Exchange management shell it doesnt give an error.
      Client Access Server Role Services: Pass
      Hub Transport Server Role Services: Pass

      What can cause this error.

      Exchange server version is 2010 SP3 UR 18

      Thank you very much / Regards

  19. TonyD

    Paul, I am having really really hard time getting to run in task scheduler. I followed your previous version guide and did what users have stated in the comments and nothing works for me. Can you please advice.
    Thank you

    1. Avatar photo

      Think of Task Scheduler as basically a cmd.exe session. If you can get a command line to run in cmd.exe, it will be easy to put it into Task Scheduler. So start in cmd.exe until you get the full command syntax correct.

      Otherwise you’ll need to be clearer about what is not working for you.

      1. TonyD

        I tried doing this from CMD

        powershell.exe -command “. ‘C:Program FilesMicrosoftExchange ServerbinRemoteExchange.ps1′; Connect-ExchangeServer -auto; C:Scripts-ExchangeServerHealthTest-ExchangeServerHealth.ps1 -reportmode $true -sendemail $true”

        And it does the command, but nothing happens.

        1. Avatar photo
          1. TonyD

            I got the task scheduler to run now. My issues is that it takes a few hours to send the reports vs running manually takes 1-2 minutes. Can you advice? I love your books, really learned alot. Thanks

  20. Carol Ostos

    Great! Thank you very much Paul

  21. Kevin

    Thank you for taking the time to continue to work on this and for sharing it Paul. It’s much appreciated.

Leave a Reply