Updated the manuals

This commit is contained in:
Markus Fleschutz
2024-03-27 17:36:59 +01:00
parent c5b5cb1c6e
commit aed2b7d940
610 changed files with 1754 additions and 1120 deletions

View File

@ -17,7 +17,7 @@ Example
-------
```powershell
PS> ./ping-local-hosts.ps1
Up: Hippo Jenkins01 Jenkins02 Rocket Vega
Up: hippo jenkins01 jenkins02 rocket vega
```
@ -39,44 +39,43 @@ Script Content
This PowerShell script pings the computers in the local network and lists which one are up.
.EXAMPLE
PS> ./ping-local-hosts.ps1
✅ Up: Hippo Jenkins01 Jenkins02 Rocket Vega
✅ Up: hippo jenkins01 jenkins02 rocket vega
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
$names = @('ad','amnesiac','archlinux','auriga','berlin','boston','brother','canon','castor','cisco','echodot','epson','fedora','fireball','firewall','fritz.box','fritz!repeater','gassensor','gateway','hippo','heizung','hodor','homemanager','io','iphone','jarvis','jenkins','la','laptop','jupiter','mars','mercury','miami','mobile','none','none-1','none-2','ny','octopi','office','officepc','paris','pi','pixel-6a','pluto','printer','proxy','r2d2','raspberry','rocket','rome','router','sentinel','server','shelly1','smartphone','smartwatch','soundbar','sunnyboy','surface','switch','tablet','tau','tigercat','tolino','tv','ubuntu','vega','venus','xrx','zeus') # sorted alphabetically
[int]$pingTimeout = 600 # ms
try {
Write-Progress "Sending pings to the local hosts..."
[string]$hosts = "Amnesiac,ArchLinux,Berlin,Boston,Brother,Canon,Castor,Cisco,EchoDot,Epson,Fedora,Fireball,Firewall,fritz.box,GasSensor,Gateway,Hippo,HomeManager,Io,iPhone,Jarvis,Jenkins01,Jenkins02,LA,Laptop,Jupiter,Mars,Mercury,Miami,Mobile,NY,OctoPi,Paris,Pixel-6a,Pluto,Printer,Proxy,R2D2,Raspberry,Rocket,Rome,Router,Server,Shelly1,SmartPhone,SmartWatch,Soundbar,Sunnyboy,Surface,Switch,Tablet,Tolino,TV,Ubuntu,Vega,Venus,XRX,Zeus" # sorted alphabetically
$hostsArray = $hosts.Split(",")
$count = $hostsArray.Count
[int]$timeout = 600 # ms
$queue = [System.Collections.Queue]::new()
foreach($hostname in $hostsArray) {
foreach($name in $names) {
$ping = [System.Net.Networkinformation.Ping]::new()
$obj = @{ Host = $hostname; Ping = $ping; Async = $ping.SendPingAsync($hostname, $timeout) }
$queue.Enqueue($obj)
$queue.Enqueue( @{Host=$name; Ping=$ping; Async=$ping.SendPingAsync($name, $pingTimeout)} )
}
[string]$result = ""
while ($queue.Count -gt 0) {
$up = ""
do {
$obj = $queue.Dequeue()
try {
if ($obj.Async.Wait($timeout) -eq $true) {
if ($obj.Async.Wait($pingTimeout)) {
if ($obj.Async.Result.Status -ne "TimedOut") {
$result += "$($obj.Host) "
$up += "$($obj.Host) "
}
continue
}
} catch {
if ($obj.Async.IsCompleted -eq $true) { continue }
if ($obj.Async.IsCompleted) { continue }
}
$queue.Enqueue($obj)
}
Write-Progress -completed "Done."
Write-Host "✅ Up: $($result)"
} while ($queue.Count -gt 0)
Write-Progress -completed "done."
Write-Host "✅ Up: $($up)"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
@ -84,4 +83,4 @@ try {
}
```
*(generated by convert-ps2md.ps1 using the comment-based help of ping-local-hosts.ps1 as of 01/25/2024 13:58:41)*
*(generated by convert-ps2md.ps1 using the comment-based help of ping-local-hosts.ps1 as of 03/27/2024 17:36:30)*