Created
August 4, 2016 04:25
-
-
Save chrisbrownie/a90764a11bb942f9bc1da4c72536792b to your computer and use it in GitHub Desktop.
Emails when a device starts replying to ICMP ping requests
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
#EmailWhenUp.ps1 | |
# Usage: ./EmailWhenUp.ps1 Computer01 | |
Param([string]$ComputerName,[string]$mailServer,[string]$MailTo) | |
function isup { | |
Param([string]$ComputerName) | |
Test-Connection -ComputerName $ComputerName -Count 1 -Quiet | |
} | |
while (isup $ComputerName -eq $false) { | |
Write-Host "Still Down" -ForegroundColor Red | |
} | |
Write-Host "Up!" -ForegroundColor green | |
Send-MailMessage -SmtpServer $mailServer -Subject "$Computername is up!" -Body "$ComputerName is up now" -From $MailTo -To $mailTo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment