Skip to content

Instantly share code, notes, and snippets.

@hapylestat
Created November 13, 2013 23:57
Show Gist options
  • Select an option

  • Save hapylestat/7458748 to your computer and use it in GitHub Desktop.

Select an option

Save hapylestat/7458748 to your computer and use it in GitHub Desktop.
Network pinger, make colored dots to help visual analyze a quality of network connection over time
#==========variables
$h="8.8.8.8"
$ping=New-object System.Net.NetworkInformation.Ping
$window=(get-host).UI.RawUI
$c=0;
#==========/variables
Write-Host "Begin => "
while ($True){
$c=0;
try{
$temp=$ping.Send($h)
$temp=$temp.RoundtripTime
$window.WindowTitle="Current ping: $temp ms"
if ($temp -eq 0 -and $c -eq 0){ Write-Host "d" -NoNewLine -ForegroundColor Red; $c=1;}
if ($temp -lt 130 -and $c -eq 0){ Write-Host "." -NoNewLine -ForegroundColor Green; $c=1;}
if ($temp -lt 200 -and $c -eq 0){ Write-Host "." -NoNewLine -ForegroundColor Yellow; $c=1;}
if ($temp -lt 300 -and $c -eq 0){ Write-Host "." -NoNewLine -ForegroundColor Red; $c=1;}
if ($temp -lt 400 -and $c -eq 0){ Write-Host "." -NoNewLine -ForegroundColor DarkRed; $c=1;}
} catch [Exception]{
Write-Host "d" -NoNewLine -ForegroundColor DarkRed;
}
Start-Sleep -s 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment