This PowerShell script will perform a health check of your Exchange Server environment, including servers and database availability groups, and output a HTML report that you can send to your inbox.

The report includes a summary of issues that were found, as well as a color-coded table with the detailed test results to help you quickly spot problems.

This is a useful script to run as a daily health check first thing in the morning to identify any problems that may have occurred overnight, and give you a chance to fix them before your end users notice.

This script is available to download from the TechNet Script Gallery or Github. Comments are welcome below. If you find a bug please consider raising it as an issue on Github.

Script parameters:

-Server , Perform a health check of a single server

, Perform a health check of a single server -ReportMode , Set to $true to generate a HTML report. A default file name is used if none is specified.

, Set to $true to generate a HTML report. A default file name is used if none is specified. -ReportFile , Allows you to specify a different HTML report file name than the default.

, Allows you to specify a different HTML report file name than the default. -SendEmail , Sends the HTML report via email using the SMTP configuration within the script.

, Sends the HTML report via email using the SMTP configuration within the script. -AlertsOnly , Only sends the email report if at least one error or warning was detected.

, Only sends the email report if at least one error or warning was detected. -Log, Writes a log file to help with troubleshooting.

Examples:

.\Test-ExchangeServerHealth.ps1 1 . \ Test - ExchangeServerHealth . ps1

Checks all servers in the organization and outputs the results to the shell window.

.\Test-ExchangeServerHealth.ps1 -Server HO-EX2010-MB1 1 . \ Test - ExchangeServerHealth . ps1 - Server HO - EX2010 - MB1

Checks the server HO-EX2010-MB1 and outputs the results to the shell window.

.\Test-ExchangeServerHealth.ps1 -ReportMode -SendEmail 1 . \ Test - ExchangeServerHealth . ps1 - ReportMode - SendEmail

Checks all servers in the organization, outputs the results to the shell window, a HTML report, and emails the HTML report to the address configured in the script.

If you use the report mode you’ll get a HTML file containing the health check results, and/or an email to your designated address if you also use the send email option.

For the email functionality to work please update these variables in the script to suit your environment.

#................................... # Modify these Email Settings #................................... $smtpsettings = @{ To = "administrator@exchangeserverpro.net" From = "exchangeserver@exchangeserverpro.net" Subject = "Exchange Server Health Report - $now" SmtpServer = "smtp.exchangeserverpro.net" } 1 2 3 4 5 6 7 8 9 10 #................................... # Modify these Email Settings #................................... $ smtpsettings = @ { To = "administrator@exchangeserverpro.net" From = "exchangeserver@exchangeserverpro.net" Subject = "Exchange Server Health Report - $now" SmtpServer = "smtp.exchangeserverpro.net" }

A lot of people ask how to add multiple recipients to the SMTP settings. My advice is to use a distribution group, so that any time you need to modify the list of recipients you can simply change the distribution group membership instead of needing to modify the script code.

When running the script on non-English servers you can modify the following variables in the script to match your language so that the script does not give errors or incorrect results.

#................................... # Modify these language # localization strings. #................................... # The server roles must match the role names you see when you run Test-ServiceHealth. $casrole = "Client Access Server Role" $htrole = "Hub Transport Server Role" $mbrole = "Mailbox Server Role" $umrole = "Unified Messaging Server Role" # This should match the word for "Success", or the result of a successful Test-MAPIConnectivity test $success = "Success" 1 2 3 4 5 6 7 8 9 10 11 12 13 #................................... # Modify these language # localization strings. #................................... # The server roles must match the role names you see when you run Test-ServiceHealth. $ casrole = "Client Access Server Role" $ htrole = "Hub Transport Server Role" $ mbrole = "Mailbox Server Role" $ umrole = "Unified Messaging Server Role" # This should match the word for "Success", or the result of a successful Test-MAPIConnectivity test $ success = "Success"

For example, a German system would use the following values:

# The server roles must match the role names you see when you run Test-ServiceHealth. $casrole = "Clientzugriffs-Serverrolle" $htrole = "Hub-Transport-Serverrolle" $mbrole = "Postfachserverrolle" $umrole = "Unified Messaging-Serverrolle" # This should match the word for "Success", or the result of a successful Test-MAPIConnectivity test $success = "Erfolgreich" 1 2 3 4 5 6 7 8 # The server roles must match the role names you see when you run Test-ServiceHealth. $ casrole = "Clientzugriffs-Serverrolle" $ htrole = "Hub-Transport-Serverrolle" $ mbrole = "Postfachserverrolle" $ umrole = "Unified Messaging-Serverrolle" # This should match the word for "Success", or the result of a successful Test-MAPIConnectivity test $ success = "Erfolgreich"

Use the ignorelist.txt file to specify the names of any servers, DAGs, or databases that you want to ignore for the tests.

My scheduled task settings for this script are:

Run whether user is logged on or not

Run with highest privileges

Action: Start a program Program: powershell.exe Arguments: -command “C:\Scripts\ExchangeServerHealth\Test-ExchangeServerHealth.ps1 -Log -SendEmail”



FAQ

Q: Which version of PowerShell is required?

If you are running the script on a server that has Exchange 2010 or 2013 (or later) server roles or management tools installed then it should work.

Q: I’m running multiple versions of Exchange, will the script still work?

Yes, it should work as long as you run it from the highest version of Exchange. For example, in a mixed Exchange 2010/2013 environment you should run the script from an Exchange 2013 server.

Q: Why do I get an error when the script sends the email report?

Make sure you’ve configured the email settings section of the script to point to a Hub Transport that either accepts anonymous users (typically an internet-facing Hub Transport), or if you’re using a separate management server or admin workstation point the SMTP server to a Hub Transport that has a receive connector set up that the server you’re running the script on is allowed to relay through.

Q: Why aren’t Edge Transport servers checked?

Between firewalls and permissions the Edge Transport checks are difficult to account for so they are currently skipped by the script.

Q: What should I do when the script report an error/fail on my servers?

The script doesn’t perform any diagnostics when it detects an error, it only reports them to you. When you see an error you should investigate further using the management tools and cmdlets that are provided by Exchange.

If you are encountering situations where the script reports errors that turn out to be false alarms please let me know and I will do my best eliminate those false alarms.

Q: Can you add feature X to the script?

If you have additional requirements then you are encouraged to customize the script to suit your own needs.