PoshCode Archive  Artifact Content

Artifact 62d99370da9eb31ad6ea6dd5d354d2749d7c1c8138da7f5878318998dbb69ad2:

  • File test-connectivity.ps1 — part of check-in [97196f35bc] at 2018-06-10 12:56:27 on branch trunk — having problems with my dsl connection, a simple pinging log script (user: karl prosser size: 975)

# encoding: utf-8
# api: powershell
# title: test connectivity
# description: having problems with my dsl connection, a simple pinging log script
# version: 0.1
# author: karl prosser
# license: CC0
# x-poshcode-id: 1112
# x-archived: 2013-07-28T13:42:10
# x-published: 2009-05-18T14:28:00
#
#


$ping = new-object System.Net.NetworkInformation.Ping
$isbad = $true;
do {
try {
    $Reply = $ping.send('www.yahoo.com')
    if ($Reply.status –ne “Success”) { $txt = "$(get-date) problem"  ; write-Host $txt ; $txt | out-File -append c:\downloads\jetstreamlog.txt} 
    else { 
        if ($isbad) {$isbad = $false;$txt = "$(get-date) RECOVERED";write-Host $txt ; $txt | out-File -append c:\downloads\jetstreamlog.txt  }
        $txt = "$(get-date) good" ;write-Host $txt }
    }
catch {
    $isbad = $true;
    $txt = "$(get-date) EXCEPTION"  ; write-Host $txt ; $txt | out-File -append c:\downloads\jetstreamlog.txt
}
sleep 4
}
while ($true)