20 November 2012

Test-ExchangeServerHealth – PowerShell Script to Generate a Health Check Report for Exchange Server 2010

I recently came across this great script, thats shows you in an email how your Exchange environment is performing.
While the script was useful it lacked a few important things. For one thing, it only checked the mailbox server role. Also, the results were only output to the shell session, not in object form, so there wasn’t much that could be done with the results.
Today I’ve released a totally overhauled and updated version of the script that addresses those problems. Before you run the script please read the guidance below, watch the demo video, and check the known bugs and FAQ at the end of this article for current issues.
 
Download the script file here: Test-ExchangeServerHealth.ps1
 
The Test-ExchangeServerHealth.ps1 script is run from the Exchange Management Shell. You can use a few builtin parameters to control what it does.
 
.PARAMETER server
Perform a health check of a single server

.PARAMETER reportmode
Set to $true to generate a HTML report. A default file name is used if none is 
specified.

.PARAMETER reportfile
Allows you to specify a different HTML report file name than the default. 
Implies -reportmode:$true

.PARAMETER sendemail
Sends the HTML report via email using the SMTP configuration within the script. 
Implies -reportmode:$true
 
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.
 
#...................................
# Email Settings
#...................................

$smtpServer = "ho-ex2010-mb1.exchangeserverpro.net"
$smtpTo = "administrator@exchangeserverpro.net"
$smtpFrom = "healthcheck@exchangeserverpro.net"
$messagesubject = "Exchange Server Health Check - $date"
 
 
Here is a demo video explaining how the different options work.

 
Download the script file here: Test-ExchangeServerHealth.ps1
 
Please feel free to download and try the script.
 
If you’re looking for an example of how to schedule the script to run using Task Scheduler please see this article.
Change Log:
  • V1.0, 5/07/2012 – Initial version
    V1.1, 5/08/2012 – Minor bug fixes and removed Edge Tranport checks

Bugs list and FAQ

Q: Which version of PowerShell is required?
Version 2.0 or higher. If you are running the script on a server that has Exchange 2010 roles or management tools installed then it will have v2.0. If you are running on an Exchange 2007 server check first whether v2.0 is installed. I don’t test the script on v1.0 but you are welcome to modify it as necessary to get it running on a v1.0 environment.
Q: Why do I get an error when the script sends the email report?
Make sure you’ve configured the $smtpserver variable in 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 $smtpserver 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 is there an error when the script checks the queue for Exchange 2007 Hub Transport servers?
This is a bug that I am working on. The script was not originally intended to be backwards compatible but I will do my best to fix this bug.
Q: Why do I get errors when the script checks my Edge Transport servers?
Between firewalls and permissions the Edge Transport checks are difficult to account for so in the next version the Edge Transport role will simply be skipped by the script.
Q: Why do I get an error on the server uptime check?
This is a bug that I am working to reproduce and eliminate.
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?
Currently I am working on the following feature improvements:
  • DAG/database copy health
  • Ability to specify a file name containing a static list of servers to check
If you have other health check related features you’d like to see included please let me know in the comments below.
 

No comments:

Post a Comment