This is post 3 in a series of 3 Exchange mini health assessment posts. The CAS role mini heath check post can be found here. The HUB mini health assessment post can be found here.

The third PS1 script is a limited health assessment for the Mailbox role. The script runs through 4 functional areas:  core Exchange service status, Test mail flow, MAPI connectivity, and ExBPA (errors are exported to the report and warnings are displayed on screen). Once the data is collected, the results are exported to a simple HTML report.

mailbox_health_script

Find the script and code here.

Get-Date | Select-Object Date | convertTo-HTML -head $a -Title "HealthCheck" | Out-File c:MBHealthReport.htm
$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>"

$MBRole = Get-mailboxserver

Foreach ($MBServer in $MBRole)
{

convertTo-HTML -head $a -Title "MB Server Health Report" -Body "<H2>$MBServer</H2>" |  Out-File c:MBHealthReport.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:MBHealthReport.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:MBHealthReport.htm -append
Test-mailflow -Identity $MBServer | convertTo-HTML -Body "<Font Color = Black><B>----------------- Test Mail Flow ---------------------</B></Font Color>"  |  Out-File c:MBHealthReport.htm -append
Test-MAPIConnectivity -Server $MBServer | convertTo-HTML -Body "<Font Color = Black><B>----------------- Test MAPI Connectiivity ---------------------</B></Font Color>"  |  Out-File c:MBHealthReport.htm -append
Test-SystemHealth  -ServerList $MBServer -DownloadConfigurationUpdates:$False 2>&1 | convertTo-HTML -body "<Font Color = Black><B>----------------------- Overall System Health -----------------</B></Font Color>" |  Out-File c:MBHealthReport.htm -append

}

Happy Exchanging!!!