mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-13 13:38:17 +02:00
Update check-ping.ps1
This commit is contained in:
parent
fa3865a9a9
commit
f60c8e0577
@ -7,7 +7,7 @@
|
||||
Specifies the hosts to check, seperated by commata (default is: amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,github.com,google.com,live.com,twitter.com,youtube.com)
|
||||
.EXAMPLE
|
||||
PS> ./check-ping
|
||||
✅ Ping latency is 13ms...109ms with 25ms average
|
||||
✅ Ping latency is 13ms...109ms with 29ms average (0 loss)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -25,18 +25,20 @@ try {
|
||||
}
|
||||
[Threading.Tasks.Task]::WaitAll($t)
|
||||
[int]$Min = 9999999
|
||||
[int]$Max = [int]$Avg = [int]$Count = 0
|
||||
[int]$Max = [int]$Avg = [int]$SuccessCount = [int]$LossCount = 0
|
||||
foreach($ping in $t.Result) {
|
||||
if ($ping.Status -eq "Success") {
|
||||
[int]$Latency = $ping.RoundtripTime
|
||||
if ($Latency -lt $Min) { $Min = $Latency }
|
||||
if ($Latency -gt $Max) { $Max = $Latency }
|
||||
$Avg += $Latency
|
||||
$Count++
|
||||
$SuccessCount++
|
||||
} else {
|
||||
$LossCount++
|
||||
}
|
||||
}
|
||||
$Avg /= $Count
|
||||
Write-Host " $($Min)ms...$($Max)ms with $($Avg)ms average"
|
||||
$Avg /= $SuccessCount
|
||||
Write-Host " $($Min)ms...$($Max)ms with $($Avg)ms average ($LossCount loss)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user