mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-17 08:01:31 +02:00
Updated the Markdown manuals
This commit is contained in:
@ -26,7 +26,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./ping-remote-hosts.ps1
|
||||
✅ Online with 18ms latency (13ms...109ms, 0/10 ping loss)
|
||||
✅ Online with 18ms latency (13...109ms, 0/10 ping loss)
|
||||
|
||||
```
|
||||
|
||||
@ -50,7 +50,7 @@ Script Content
|
||||
Specifies the hosts to ping, seperated by commata (10 Internet servers by default)
|
||||
.EXAMPLE
|
||||
PS> ./ping-remote-hosts.ps1
|
||||
✅ Online with 18ms latency (13ms...109ms, 0/10 ping loss)
|
||||
✅ Online with 18ms latency (13...109ms, 0/10 ping loss)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -61,14 +61,12 @@ param([string]$hosts = "bing.com,cnn.com,dropbox.com,github.com,google.com,ibm.c
|
||||
|
||||
try {
|
||||
$hostsArray = $hosts.Split(",")
|
||||
$parallelTasks = $hostsArray | foreach {
|
||||
(New-Object Net.NetworkInformation.Ping).SendPingAsync($_,750)
|
||||
}
|
||||
$tasks = $hostsArray | foreach { (New-Object Net.NetworkInformation.Ping).SendPingAsync($_,750) }
|
||||
[int]$min = 9999999
|
||||
[int]$max = [int]$avg = [int]$success = 0
|
||||
[int]$total = $hostsArray.Count
|
||||
[Threading.Tasks.Task]::WaitAll($parallelTasks)
|
||||
foreach($ping in $parallelTasks.Result) {
|
||||
[Threading.Tasks.Task]::WaitAll($tasks)
|
||||
foreach($ping in $tasks.Result) {
|
||||
if ($ping.Status -ne "Success") { continue }
|
||||
$success++
|
||||
[int]$latency = $ping.RoundtripTime
|
||||
@ -79,7 +77,7 @@ try {
|
||||
[int]$loss = $total - $success
|
||||
if ($success -ne 0) {
|
||||
$avg /= $success
|
||||
Write-Host "✅ Online with $($avg)ms latency ($($min)ms...$($max)ms, $loss/$total ping loss)"
|
||||
Write-Host "✅ Online with $($avg)ms latency ($($min)...$($max)ms, $loss/$total ping loss)"
|
||||
} else {
|
||||
Write-Host "⚠️ Offline ($loss/$total ping loss)"
|
||||
}
|
||||
@ -90,4 +88,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of ping-remote-hosts.ps1 as of 03/27/2024 17:36:30)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of ping-remote-hosts.ps1 as of 05/19/2024 10:25:24)*
|
||||
|
Reference in New Issue
Block a user