mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-21 17:38:19 +02:00
Updated ping-local-hosts.ps1
This commit is contained in:
parent
1640c9349d
commit
1d1ad6c85a
@ -16,8 +16,6 @@ param([int]$timeout = 600) # ms ping timeout
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Write-Progress "Sending pings to the local hosts..."
|
|
||||||
|
|
||||||
$names = @('accesspoint','AD','AP','amnesiac','archlinux','auriga','berlin','boston','brother','canon','castor','cisco','echodot','epson','epson2550','epson2815','fedora','fireball','firewall','fritz.box','fritz.repeater','gassensor','gateway','hippo','heizung','hodor','homemanager','io','iphone','jarvis','jenkins','LA','laptop','linux','jupiter','mars','mercury','miami','mobile','none','none-1','none-2','NY','octo','office','officepc','paris','PI','pixel-6a','PC','pluto','printer','proxy','R2D2','raspberry','rocket','rome','router','sentinel','server','shelly','shelly1','smartphone','smartwatch','soundbar','sunnyboy','surface','switch','tablet','tau','tigercat','tolino','TV','ubuntu','vega','venus','xrx','zeus') # sorted alphabetically
|
$names = @('accesspoint','AD','AP','amnesiac','archlinux','auriga','berlin','boston','brother','canon','castor','cisco','echodot','epson','epson2550','epson2815','fedora','fireball','firewall','fritz.box','fritz.repeater','gassensor','gateway','hippo','heizung','hodor','homemanager','io','iphone','jarvis','jenkins','LA','laptop','linux','jupiter','mars','mercury','miami','mobile','none','none-1','none-2','NY','octo','office','officepc','paris','PI','pixel-6a','PC','pluto','printer','proxy','R2D2','raspberry','rocket','rome','router','sentinel','server','shelly','shelly1','smartphone','smartwatch','soundbar','sunnyboy','surface','switch','tablet','tau','tigercat','tolino','TV','ubuntu','vega','venus','xrx','zeus') # sorted alphabetically
|
||||||
$queue = [System.Collections.Queue]::new()
|
$queue = [System.Collections.Queue]::new()
|
||||||
foreach($name in $names) {
|
foreach($name in $names) {
|
||||||
@ -26,17 +24,15 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[string]$up = ""
|
[string]$up = ""
|
||||||
|
Write-Host "✅ Up: " -noNewline
|
||||||
while ($queue.Count -gt 0) { $obj = $queue.Dequeue()
|
while ($queue.Count -gt 0) { $obj = $queue.Dequeue()
|
||||||
try { if ($obj.Async.Wait($timeout)) {
|
try { if ($obj.Async.Wait($timeout)) {
|
||||||
if ($obj.Async.Result.Status -ne "TimedOut") { $up += "$($obj.Host) " }
|
if ($obj.Async.Result.Status -ne "TimedOut") { Write-Host "$($obj.Host) " -noNewline }
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} catch { continue }
|
} catch { continue }
|
||||||
$queue.Enqueue($obj)
|
$queue.Enqueue($obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Progress -completed "Done."
|
|
||||||
Write-Host "✅ Up: $up"
|
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user