mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-15 17:36:48 +02:00
Update check-ping.ps1
This commit is contained in:
parent
0bf94c16fb
commit
d23eebc023
@ -20,7 +20,7 @@ param([string]$hosts = "amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,goo
|
|||||||
try {
|
try {
|
||||||
write-progress "Sending pings to $hosts..."
|
write-progress "Sending pings to $hosts..."
|
||||||
$HostsArray = $hosts.Split(",")
|
$HostsArray = $hosts.Split(",")
|
||||||
$Pings = test-connection -count 1 -computerName $HostsArray
|
$Pings = Test-Connection -count 1 -computerName $HostsArray
|
||||||
|
|
||||||
[int]$Min = 9999999
|
[int]$Min = 9999999
|
||||||
[int]$Max = 0
|
[int]$Max = 0
|
||||||
@ -35,8 +35,8 @@ try {
|
|||||||
if ($Latency -gt $Max) { $Max = $Latency }
|
if ($Latency -gt $Max) { $Max = $Latency }
|
||||||
$Avg += $Latency
|
$Avg += $Latency
|
||||||
}
|
}
|
||||||
$Avg = $Avg / $Pings.count
|
$Avg /= $Pings.count
|
||||||
"✅ Ping is $($Avg)ms average, $($Min)ms minimum, $($Max)ms maximum."
|
"✅ Ping is $($Avg)ms average, $($Min)ms min, $($Max)ms max."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user