Check-ConnectionStatus {
# SMTP Variables
$smtp = 'mail.xxxx.com'
$to = 'name@xxxx.com'
$from = 'PowerShell@xxxx.com'
$subject = 'xxxx Connection is Down'
# Wan Variables
#HP_ERP - Primary IP Address
$ERP Server = 'x.x.x.x'
#Local - IP Address
$local = 'x..x..x..x'
test-connection $ERP Server
}
catch {
}
}
process {
try {
if (test-connection $ERP Server -quiet) { $null } else
{
Write-Output "ERP_Server {$ERP Server } is Down. The Current Static IP is : $local ."
$body = "ERP Server Connection {$ERP Server} is Down."
$body += "`n"
$body += "`n"
Send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -Priority 'High' -UseSsl
}
else
{
Write-Output "All is Well"
}
}
catch {
}
}
end {
try {
}
catch {
}
}
}