Skip to content

Instantly share code, notes, and snippets.

@elvarb
Created May 8, 2012 10:19
Show Gist options
  • Save elvarb/2634066 to your computer and use it in GitHub Desktop.
Save elvarb/2634066 to your computer and use it in GitHub Desktop.
Powershell: Pingcheck
$servers = "microsoft.com","google.com"
$servers | %{
if (test-Connection -ComputerName $_ -Count 2 -Quiet ) {
echo "$_ is online!"
} else {
$emailFrom = "[email protected]"
$emailTo = "[email protected]"
$subject = "$_ Is down!"
$body = "Holy shit, you should do something about this."
$smtpServer = "your smtp server"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment