Created
May 8, 2012 10:19
-
-
Save elvarb/2634066 to your computer and use it in GitHub Desktop.
Powershell: Pingcheck
This file contains hidden or 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
$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