mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-11 13:53:42 +02:00
Updated ping-internet.ps1
This commit is contained in:
@ -1,13 +1,13 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Pings remote hosts to measure the latency
|
Measures the latency to Internet hosts
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script measures the ping roundtrip times from the local computer to remote ones (10 Internet servers by default).
|
This PowerShell script measures the ping roundtrip times from the local computer to 10 Internet servers.
|
||||||
.PARAMETER hosts
|
.PARAMETER hosts
|
||||||
Specifies the hosts to ping, seperated by commata (10 Internet servers by default)
|
Specifies the hosts to ping, seperated by commata (10 Internet servers by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./ping-internet.ps1
|
PS> ./ping-internet.ps1
|
||||||
✅ Internet ping: 12ms (9...18ms range)
|
✅ Internet ping is 12ms (9...18ms range)
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -39,10 +39,10 @@ try {
|
|||||||
Write-Host "✅ Online with $loss/$total ping loss and $($min)...$($max)ms latency - $($speed)ms average"
|
Write-Host "✅ Online with $loss/$total ping loss and $($min)...$($max)ms latency - $($speed)ms average"
|
||||||
} else {
|
} else {
|
||||||
[float]$speed = [math]::round([float]$avg / [float]$success, 1)
|
[float]$speed = [math]::round([float]$avg / [float]$success, 1)
|
||||||
Write-Host "✅ Internet ping: $($speed)ms ($min...$($max)ms range)"
|
Write-Host "✅ Internet ping is $($speed)ms ($min...$($max)ms range)"
|
||||||
}
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user