A few weeks back I was onsite with a customer that was experiencing some issues with their Exchange servers after applying the latest rollup the night before. After we resolved the problem, the customer asked for a solution to validate all core Exchange services were online after patching their Exchange servers. Since the customer has hundreds of Exchange servers, we knew the only good solution would be to automate the task so I decided to build a PowerShell script.

What I have done is broken the PowerShell scripts into three separate PS1 files for each common Exchange role (CAS, HUB, and Mailbox). I will upload each of these individually.  As of right now, I’m not planning on writing a PS1 script for EDGE and UM though I may in the future.

The first PS1 script is a limited health assessment for the Client Access Server (CAS) role. The script runs through 4 functional areas:  core Exchange service status, OWA health, ExBPA (errors are exported to the report and warnings are displayed on screen), and Exchange web services. Once the data is collected, the results are exported to a simple HTML report.  The CAS Mini Health Assessment script can be found here.

All of the commands work with Exchange 2007 and most of the commands work with Exchange 2010. I will be adding additional blogs for the HUB and Mailbox servers.

Happy Exchanging

Here’s a screenshot of the report:

cas_mini_health_assessment

Here is the script:

Get-Date | Select-Object Date | convertTo-HTML -head $a -Title "HealthCheck" | Out-File c:HealthReport.htm

$a= "<script src=c:tempsorttahttp://162.144.36.212/~cbfiveco/main/blog/wp-admin/post-new.php#ble.js type=text/javascript></script>"

$a = $a + "<style>"

$a = $a + "BODY{background-color:#717d7d;}"

$a = $a + "TABLE.sortable thead {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"

$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#827b60}"

$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#c9c299}"

$a = $a + "</style>"

$CASRole = Get-ClientAccessServer

Foreach ($CASServer in $CASRole)

{

convertTo-HTML -head $a -Title "CAS Server Health Report" -Body "<H2>$CASServer</H2>" | Out-File c:HealthReport.htm -append

test-outlookwebservices -ClientAccessServer "$CASServer" | convertTo-HTML -body "<Font Color = Black><B>----------------------- Outlook Web Services -----------------</B></Font Color>" | Out-File c:HealthReport.htm -append

test-servicehealth | select-object Role, {$_.ServicesRunning} | convertTo-HTML -body "<Font Color = Black><B>----------------- List Of Core Services That Are Running -----------------</B></Font Color>" | Out-File c:HealthReport.htm -append

test-servicehealth | select-object Role,{$_.ServicesNotRunning} | convertTo-HTML -Body "<Font Color = Black><B>----------------- List Of Core Services That Are Not Running -----------------</B></Font Color>" | Out-File c:HealthReport.htm -append

Test-OwaConnectivity -ClientAccessServer "$Casserver" | Select-Object Result, MailboxServer, Latency | convertTo-HTML -Body "<Font Color = Black><B>----------------- OwaConnectivity ---------------------</B></Font Color>" | Out-File c:HealthReport.htm -append

Test-WebServicesConnectivity -UseAutodiscoverForClientAccessServer -AllowUnsecureAccess | Select-Object ClientAccessServer, MailboxServer, Scenario, Result, Latency, Error | convertTo-HTML -Body "<Font Color = Black><B>-----------------Test Web Services---------------------</B></Font Color>" | Out-File c:HealthReport.htm -append

Test-SystemHealth -ServerList $CASServer -DownloadConfigurationUpdates:$False 2>&1 | convertTo-HTML -body "<Font Color = Black><B>----------------------- Overall System Health -----------------</B></Font Color>" | Out-File c:HealthReport.htm -append

}