Updated some check-*.ps1 scripts

This commit is contained in:
Markus Fleschutz 2022-12-28 17:49:03 +01:00
parent 3fdab43903
commit 4ada589b40
7 changed files with 32 additions and 22 deletions

View File

@ -13,13 +13,13 @@
#> #>
try { try {
$Path = Resolve-Path "$HOME/.ssh" $Path = Resolve-Path "~/.ssh"
if (-not(Test-Path "$Path" -pathType container)) { if (Test-Path "$Path" -pathType container) {
throw "SSH folder at 📂$Path doesn't exist (yet)" Set-Location "$Path"
"📂$Path"
exit 0 # success
} }
Set-Location "$Path" throw "User's SSH folder at 📂$Path doesn't exist (yet)"
"📂$Path"
exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1 exit 1

View File

@ -55,17 +55,19 @@ try {
$Arch = "" $Arch = ""
} }
if ([System.Environment]::Is64BitOperatingSystem) { $Bits = "64-bit" } else { $Bits = "32-bit" } if ([System.Environment]::Is64BitOperatingSystem) { $Bits = "64-bit" } else { $Bits = "32-bit" }
$Cores = [System.Environment]::ProcessorCount $CPUName = "$Arch CPU $Bits"
"$Status $Arch CPU $Bits ($Cores cores, $Temp)" $DeviceID = ""
$Speed = ""
$Socket = ""
} else { } else {
$Details = Get-WmiObject -Class Win32_Processor $Details = Get-WmiObject -Class Win32_Processor
$CPUName = $Details.Name.trim() $CPUName = $Details.Name.trim()
$Cores = [System.Environment]::ProcessorCount $DeviceID = "$($Details.DeviceID), "
$DeviceID = $Details.DeviceID $Speed = "$($Details.MaxClockSpeed)MHz, "
$Speed = "$($Details.MaxClockSpeed)MHz" $Socket = "$($Details.SocketDesignation) socket, "
$Socket = $Details.SocketDesignation
"$Status $CPUName ($Cores cores, $DeviceID, $Speed, $Socket socket, $Temp)"
} }
$Cores = [System.Environment]::ProcessorCount
Write-Host "$Status $CPUName ($Cores cores, $($DeviceID)$($Speed)$($Socket)$Temp)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -25,8 +25,11 @@ try {
} }
[float]$Elapsed = $StopWatch.Elapsed.TotalSeconds [float]$Elapsed = $StopWatch.Elapsed.TotalSeconds
Write-Progress -Completed " "
$Average = [math]::round($NumRows / $Elapsed, 1) $Average = [math]::round($NumRows / $Elapsed, 1)
if ($Average -gt 10.0) { if ($Average -gt 100.0) {
"✅ DNS resolves excellent $Average domains per second"
} elseif ($Average -gt 10.0) {
"✅ DNS resolves $Average domains per second" "✅ DNS resolves $Average domains per second"
} else { } else {
"⚠️ DNS resolves only $Average domains per second!" "⚠️ DNS resolves only $Average domains per second!"

View File

@ -36,7 +36,7 @@ try {
$RefreshRate = $Details.CurrentRefreshRate $RefreshRate = $Details.CurrentRefreshRate
$DriverVersion = $Details.DriverVersion $DriverVersion = $Details.DriverVersion
$Status = $Details.Status $Status = $Details.Status
"$Model GPU ($(Bytes2String $RAMSize) RAM, $($ResWidth)x$($ResHeight) pixels, $BitsPerPixel bit, $RefreshRate Hz, driver $DriverVersion, status $Status)" Write-Host "$Model GPU ($(Bytes2String $RAMSize) RAM, $($ResWidth)x$($ResHeight) pixels, $BitsPerPixel bit, $RefreshRate Hz, driver $DriverVersion, status $Status)"
} }
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -31,8 +31,10 @@
& "$PSScriptRoot/check-uptime.ps1" & "$PSScriptRoot/check-uptime.ps1"
& "$PSScriptRoot/check-time-zone.ps1" & "$PSScriptRoot/check-time-zone.ps1"
& "$PSScriptRoot/check-swap-space.ps1" & "$PSScriptRoot/check-swap-space.ps1"
& "$PSScriptRoot/check-dns.ps1"
& "$PSScriptRoot/check-ping.ps1"
& "$PSScriptRoot/check-vpn.ps1"
& "$PSScriptRoot/check-pending-reboot.ps1" & "$PSScriptRoot/check-pending-reboot.ps1"
" "
& "$PSScriptRoot/write-green.ps1" " N E T W O R K"
& "$PSScriptRoot/check-ping.ps1"
& "$PSScriptRoot/check-dns.ps1"
& "$PSScriptRoot/check-vpn.ps1"
exit 0 # success exit 0 # success

View File

@ -7,7 +7,7 @@
Specifies the hosts to check, seperated by comma (default is: amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com) Specifies the hosts to check, seperated by comma (default is: amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com)
.EXAMPLE .EXAMPLE
PS> ./check-ping PS> ./check-ping
Ping is 25ms average, 13ms min, 109ms max. Ping is 25ms average, 13ms min, 109ms max
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -17,10 +17,11 @@
param([string]$hosts = "amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com") param([string]$hosts = "amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com")
try { try {
Write-Progress "Pinging $hosts..." Write-Progress "(1/2) Pinging $hosts..."
$HostsArray = $hosts.Split(",") $HostsArray = $hosts.Split(",")
$Pings = Test-Connection -count 1 -computerName $HostsArray $Pings = Test-Connection -count 1 -computerName $HostsArray
Write-Progress "⏳ (2/2) Calculating results..."
[int]$Min = 9999999 [int]$Min = 9999999
[int]$Max = [int]$Avg = 0 [int]$Max = [int]$Avg = 0
foreach($Ping in $Pings) { foreach($Ping in $Pings) {
@ -30,6 +31,8 @@ try {
$Avg += $Latency $Avg += $Latency
} }
$Avg /= $Pings.count $Avg /= $Pings.count
Write-Progress -Completed " "
"✅ Ping is $($Avg)ms average, $($Min)ms min, $($Max)ms max" "✅ Ping is $($Avg)ms average, $($Min)ms min, $($Max)ms max"
exit 0 # success exit 0 # success
} catch { } catch {

View File

@ -69,7 +69,7 @@ try {
[float]$Voltage = $Bank.ConfiguredVoltage / 1000.0 [float]$Voltage = $Bank.ConfiguredVoltage / 1000.0
$Manufacturer = $Bank.Manufacturer $Manufacturer = $Bank.Manufacturer
$Location = "$($Bank.BankLabel)/$($Bank.DeviceLocator)" $Location = "$($Bank.BankLabel)/$($Bank.DeviceLocator)"
"$Capacity $Type ($($Speed)MHz, $($Voltage)V) at $Location by $Manufacturer" Write-Host "$Capacity $Type ($($Speed)MHz, $($Voltage)V) at $Location by $Manufacturer"
} }
} }
exit 0 # success exit 0 # success