Apr 17

HealthCheck Script

I use this to run a quick HealthCheck on all my CAS services. You should probably be checking this on your NLB and whatever monitoring platform you are using.

The script runs against the virtual directories of each CAS server in your Exchange environment and returns the results in a table. A 200 response means the HealthCheck passed. A – means the HealthCheck did not respond which indicates a failure of that service.

I didn’t want to have to rely on the Exchange Management Shell to run this so both the Virtual Directory paths and the Server names are manually set and will need to be modified to fit your organization.

# Checks the state of the various http connections
# Author: Will Perry

# Set the paths of each virtual directory you want to check here.
$paths = @()
$paths += “https:///owa/healthcheck.htm”
$paths += “https:///Microsoft-Server-ActiveSync/healthcheck.htm”
$paths += “https:///ecp/healthcheck.htm”
$paths += “https:///OAB/healthcheck.htm”
$paths += “https:///powershell/healthcheck.htm”
$paths += “https:///Autodiscover/healthcheck.htm”

# List all active CAS servers Here
$servers = @()
$servers += “CAS01.domain.com”
$servers += “CAS02.domain.com”

$results = @()
foreach($path in $paths){
foreach($server in $servers){
$url = $path.Replace(“”,$server)
$result = $null
$result = Invoke-WebRequest -Uri $url
if($result -ne $null){ $statusCode = $result.StatusCode }
else{ $statusCode = “-” }

$results += New-Object PSObject -Property @{Server = $server;URL = $url;StatusCode = $statusCode}
$results += New-Object PSObject -Property @{Server = “”;URL = “”;StatusCode = “”}

Permanent link to this article: https://www.wperry.net/code/healthcheck-script/

Leave a Reply

Your email address will not be published.