mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-22 09:58:19 +02:00
Update ping-remote-hosts.ps1
This commit is contained in:
parent
c96f45fb42
commit
03175642e1
@ -7,7 +7,7 @@
|
|||||||
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-remote-hosts.ps1
|
PS> ./ping-remote-hosts.ps1
|
||||||
✅ Online with 18ms latency (13...109ms, 0/10 ping loss)
|
✅ Online with 0/10 ping loss and 11...40ms latency - 18ms average
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -18,7 +18,7 @@ param([string]$hosts = "bing.com,cnn.com,dropbox.com,github.com,google.com,ibm.c
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$hostsArray = $hosts.Split(",")
|
$hostsArray = $hosts.Split(",")
|
||||||
$tasks = $hostsArray | foreach { (New-Object Net.NetworkInformation.Ping).SendPingAsync($_,750) }
|
$tasks = $hostsArray | foreach { (New-Object Net.NetworkInformation.Ping).SendPingAsync($_,1000) }
|
||||||
[int]$min = 9999999
|
[int]$min = 9999999
|
||||||
[int]$max = [int]$avg = [int]$success = 0
|
[int]$max = [int]$avg = [int]$success = 0
|
||||||
[int]$total = $hostsArray.Count
|
[int]$total = $hostsArray.Count
|
||||||
@ -34,7 +34,7 @@ try {
|
|||||||
[int]$loss = $total - $success
|
[int]$loss = $total - $success
|
||||||
if ($success -ne 0) {
|
if ($success -ne 0) {
|
||||||
$avg /= $success
|
$avg /= $success
|
||||||
Write-Host "✅ Online with $($avg)ms latency ($($min)...$($max)ms, $loss/$total ping loss)"
|
Write-Host "✅ Online with $loss/$total ping loss and $($min)...$($max)ms latency - $($avg)ms average"
|
||||||
} else {
|
} else {
|
||||||
Write-Host "⚠️ Offline ($loss/$total ping loss)"
|
Write-Host "⚠️ Offline ($loss/$total ping loss)"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user