Skip to content

Instantly share code, notes, and snippets.

@martin9700
Created January 12, 2014 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save martin9700/8390843 to your computer and use it in GitHub Desktop.
Save martin9700/8390843 to your computer and use it in GitHub Desktop.
$Data = $Status.Values | Where { $_.'Failed Pings' -eq 3 -or ( ($_.'Failed Pings' -ne 0 -and -not ($_.'Failed Pings' % $Alert))) }
If ($Data)
{ $HTML = $Data | Sort Destination,From | ConvertTo-Html -Head $Header -PreContent "<p>Ping Detection Script has detected <i>failed</i> connections!<br></p>" | Out-String
Send-MailMessage -To $To -From $From -Subject "Connections lost!" -Body $HTML -BodyAsHtml -SmtpServer $SMTPServer
Write-Host "Alert Email Sent!`n"
Start-Sleep -Seconds 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment