$target = $args if ((($target).length) -lt "1") { Write-Warning "No Target IP Specified." Write-Warning "EXAMPLE: Check-Pings.ps1 www.google.com" break } $didnt = 0 $worked = 0 $datetime = (get-date) write-host "`nLoading..." -nonewline -foregroundcolor yellow $ping = new-object System.Net.NetworkInformation.Ping write-host "`rStarted ping to $target $datetime`n" while (1) { $go = $ping.send("$target") $result = $go.status $ms = $go.roundtriptime $ip = ($ping.send("$target").address).ipaddresstostring if ($result -match "Success") { $time = (get-date) $worked = ($worked + 1) if ($didnt -gt "0") { $failrate = ( ($didnt / $worked ) * 100).tostring(".0") write-host `r"Ping Successful ($ip) - $time - $failrate% Loss - $ms ms " -nonewline -foregroundcolor green } else { write-host `r"Ping Successful ($ip) - $time - 0% Loss - $ms ms " -nonewline -foregroundcolor green } } Else { $time = (get-date) $didnt = ($didnt + 1) if ($worked -gt "0") { $failrate = ( ($didnt / $worked ) * 100).tostring(".0") write-host `r"Ping Failed - $ip - $time - $failrate% Loss ($didnt lost) "`n -nonewline -foregroundcolor red write-host " " -nonewline } else { $didnt = ($didnt - 1) write-host `r"$ip - $time - Host not sucessfully pinged yet. " -nonewline -foregroundcolor red } } sleep -milliseconds 500 }