Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Connection time out Email Alert

$
0
0

 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 { 

        } 

    } 

}

 

 

 

How can i run on time, I don`t want to run with Scheduler.

Viewing all articles
Browse latest Browse all 6937

Trending Articles