Skip to content

Instantly share code, notes, and snippets.

@chrisbrownie
Created August 4, 2016 04:25
Show Gist options
  • Save chrisbrownie/a90764a11bb942f9bc1da4c72536792b to your computer and use it in GitHub Desktop.
Save chrisbrownie/a90764a11bb942f9bc1da4c72536792b to your computer and use it in GitHub Desktop.
Emails when a device starts replying to ICMP ping requests
#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