Created
January 12, 2014 21:28
-
-
Save martin9700/8390806 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Back = @() | |
ForEach ($Result in $Results) | |
{ $Key = "$($Result.PSComputerName):$($Result.Address)" | |
$Status[$Key].'IP Address' = $Result.IPV4Address | |
If ($Result.StatusCode -eq 0) | |
{ If ($Status[$Key].'Failed Pings' -ge 3) | |
{ $Back += [PSCustomObject]@{ | |
Destination = $Result.Address | |
From = $Result.PSComputerName | |
IPAddress = $Result.IPV4Address | |
Status = "Connectivity Returned" | |
} | |
} | |
$Status[$Key].'Failed Pings' = 0 | |
} | |
Else | |
{ $Status[$Key].'Failed Pings' ++ | |
} | |
} | |
If ($Back) | |
{ $HTML = $Back | Sort Destination,From | ConvertTo-Html -Head $Header -PreContent "<p>Ping Detection Script has detected <i>restored</i> connections!<br></p>" | Out-String | |
Send-MailMessage -To $To -From $From -Subject "Connections Restored" -Body $HTML -BodyAsHtml -SmtpServer $SMTPServer | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment