Skip to content

Commit

Permalink
Merge branch 'main' of github.com:fleschutz/PowerShell
Browse files Browse the repository at this point in the history
  • Loading branch information
fleschutz committed May 18, 2024
2 parents 99def28 + 5d4df61 commit c24030c
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 14 deletions.
3 changes: 1 addition & 2 deletions scripts/check-hardware.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
Author: Markus Fleschutz | License: CC0
#>

" "
& "$PSScriptRoot/write-green.ps1" " H A R D W A R E"
Write-Host "`n H A R D W A R E" -foregroundColor green
& "$PSScriptRoot/check-cpu.ps1"
& "$PSScriptRoot/check-ram.ps1"
& "$PSScriptRoot/check-gpu.ps1"
Expand Down
3 changes: 1 addition & 2 deletions scripts/check-network.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
Author: Markus Fleschutz | License: CC0
#>

" "
& "$PSScriptRoot/write-green.ps1" " N E T W O R K"
Write-Host "`n N E T W O R K" -foregroundColor green
& "$PSScriptRoot/ping-remote-hosts.ps1"
& "$PSScriptRoot/check-firewall"
& "$PSScriptRoot/check-dns.ps1"
Expand Down
3 changes: 1 addition & 2 deletions scripts/check-software.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
Author: Markus Fleschutz | License: CC0
#>

" "
& "$PSScriptRoot/write-green.ps1" " S O F T W A R E"
Write-Host "`n S O F T W A R E" -foregroundColor green
& "$PSScriptRoot/check-os.ps1"
& "$PSScriptRoot/check-uptime.ps1"
& "$PSScriptRoot/check-apps.ps1"
Expand Down
6 changes: 3 additions & 3 deletions scripts/check-vpn.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ try {
if ($IsLinux) {
# TODO
} else {
$Connections = Get-VPNConnection
foreach($Connection in $Connections) {
Write-Host "✅ VPN to $($Connection.Name) is $($Connection.ConnectionStatus.ToLower())"
$connections = Get-VPNConnection
foreach($connection in $connections) {
Write-Host "✅ VPN to $($connection.Name) is $($connection.ConnectionStatus.ToLower())"
$noVPN = $false
}
}
Expand Down
Empty file modified scripts/list-network-neighbors.ps1
100644 → 100755
Empty file.
Empty file modified scripts/new-dir.ps1
100644 → 100755
Empty file.
11 changes: 6 additions & 5 deletions scripts/ping-local-hosts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@
Author: Markus Fleschutz | License: CC0
#>

$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
[int]$timeout = 600 # ms ping timeout
param([int]$timeout = 600) # ms ping timeout


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
$queue = [System.Collections.Queue]::new()
foreach($name in $names) {
$ping = [System.Net.Networkinformation.Ping]::new()
$queue.Enqueue( @{Host=$name; Ping=$ping; Async=$ping.SendPingAsync($name, $timeout)} )
}

$up = ""
[string]$up = ""
while ($queue.Count -gt 0) { $obj = $queue.Dequeue()
try { if ($obj.Async.Wait($timeout)) {
if ($obj.Async.Result.Status -ne "TimedOut") { $up += "$($obj.Host) " }
Expand All @@ -34,8 +35,8 @@ try {
$queue.Enqueue($obj)
}

Write-Progress -completed "done."
Write-Host "✅ Up: $($up)"
Write-Progress -completed "Done."
Write-Host "✅ Up: $up"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
Expand Down
13 changes: 13 additions & 0 deletions scripts/scan-network.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$a = Get-NetIPAddress | Where-Object -FilterScript { $_.SuffixOrigin -eq "DHCP" -or $_.SuffixOrigin -eq "manual" } # | Format-Table -property IPAddress -autoSize

$arguments = "-sT -T3" # Set sane defaults for command string
$location = "nmap" # In case nmap is not in PATH
$targets = ""

foreach ( $i in $a ) {
$s = $i.IPAddress + "/" + $i.PrefixLength
$targets = $targets + " " + $s
}
$arguments = $arguments + " " + $targets

Start-Process $location -ArgumentList $arguments -Wait
Empty file modified scripts/watch-news.ps1
100644 → 100755
Empty file.

0 comments on commit c24030c

Please sign in to comment.