Geek with special skills

Exchange 2010 healt check script

# Get-Service | where {$_.displayName -match “exch*”}

$ServerList = Get-Content “sl.txt”

$report = “report.htm”

Clear-Content $report

$sendEmail = $false

Add-Content $report “<html>”

Add-Content $report “<head>”

Add-Content $report “<meta http-equiv=’Content-Type’ content=’text/html; charset=iso-8859-1′>”

Add-Content $report ‘<title>EVOLVE.COM Exchange Service Monitor Report</title>’

add-content $report ‘<STYLE TYPE=”text/css”>’

add-content $report  “<!–”

add-content $report  “td {“

add-content $report  “font-family: Tahoma;”

add-content $report  “font-size: 11px;”

add-content $report  “border-top: 1px solid #999999;”

add-content $report  “border-right: 1px solid #999999;”

add-content $report  “border-bottom: 1px solid #999999;”

add-content $report  “border-left: 1px solid #999999;”

add-content $report  “padding-top: 0px;”

add-content $report  “padding-right: 0px;”

add-content $report  “padding-bottom: 0px;”

add-content $report  “padding-left: 0px;”

add-content $report  “}”

add-content $report  “body {“

add-content $report  “margin-left: 5px;”

add-content $report  “margin-top: 5px;”

add-content $report  “margin-right: 0px;”

add-content $report  “margin-bottom: 10px;”

add-content $report  “”

add-content $report  “table {“

add-content $report  “border: thin solid #000000;”

add-content $report  “}”

add-content $report  “–>”

add-content $report  “</style>”

Add-Content $report “</head>”

Add-Content $report “<body>”

add-content $report  “<table width=’100%’>”

add-content $report  “<tr bgcolor=’#CCCCCC’>”

add-content $report  “<td colspan=’7′ height=’25′ align=’center’>”

add-content $report  “<font face=’tahoma’ color=’#003399′
size=’4′><strong>EVOLVE.COM Exchange Service Monitor

add-content $report  “</td>”

add-content $report  “</tr>”

add-content $report  “</table>”
add-content $report  “<table width=’100%’>”

Add-Content $report “<tr bgcolor=#CCCCCC>”

Add-Content $report  “<td width=’10%’ align=’center’>Server Name</td>”

Add-Content $report “<td width=’50%’ align=’center’>Service Name</td>”

Add-Content $report  “<td width=’10%’ align=’center’>Status</td>”

Add-Content $report “</tr>”
foreach ($machineName in $serverlist)


# Write-Host $machineName

#$serviceStatus = get-WmiObject win32_service -ComputerName $machineName
| where {$_.displayName -match “exch*”} | where {$_.StartMode -match
“Auto”} | Select-Object state,name

$serviceStatus = get-WmiObject win32_service -ComputerName $machineName |
where {$_.displayName -match “exch*”} | where {$_.StartMode -match
“Auto”} | where {$_.state -match “Stopped”} | Select-Object state,name

foreach ($service in $serviceStatus)


Write-Host $machineName `t $ `t $service.state -ForegroundColor Red

$svcName = $

$svcState = $service.state

#Add-Content $report “$machineName `t $svcName `t $svcState `r”

Add-Content $report “<tr>”

Add-Content $report “<td>$machineName</td>”

Add-Content $report “<td>$svcName</td>”

Add-Content $report “<td bgcolor=’#FF0000′ align=center>$svcState</td>”

Add-Content $report “</tr>”

$sendEmail = $true


Add-content $report  “</table>”

Add-Content $report “</body>”

Add-Content $report “</html>”
if ($sendEmail =  $true)


$smtphost = “hub1″

$from = “

$to = “

$subject = “Exchange Service Monitor”

$body = Get-Content $report

$smtp= New-Object System.Net.Mail.SmtpClient $smtphost

$msg = New-Object System.Net.Mail.MailMessage $from, $to, $subject, $body

$msg.isBodyhtml = $true




No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: