Update some check-*.ps1 scripts

This commit is contained in:
Markus Fleschutz 2022-10-09 19:16:32 +02:00
parent 888e0a5408
commit 945914a326
4 changed files with 24 additions and 24 deletions

View File

@ -22,15 +22,15 @@ try {
$Temp = [math]::round($Temp / 100.0, 1) $Temp = [math]::round($Temp / 100.0, 1)
} }
if ($Temp -gt 80) { if ($Temp -gt 80) {
$Reply = "⚠️ CPU has $($Temp)°C - too hot!" $Reply = "⚠️ CPU is too hot at $($Temp)°C!"
} elseif ($Temp -gt 50) { } elseif ($Temp -gt 50) {
$Reply = "✅ CPU has $($Temp)°C - hot." $Reply = "✅ CPU is $($Temp)°C hot."
} elseif ($Temp -gt 0) { } elseif ($Temp -gt 0) {
$Reply = "✅ CPU has $($Temp)°C - warm." $Reply = "✅ CPU is $($Temp)°C warm."
} elseif ($Temp -gt -20) { } elseif ($Temp -gt -20) {
$Reply = "✅ CPU has $($Temp)°C - cold." $Reply = "✅ CPU is $($Temp)°C cold."
} else { } else {
$Reply = "⚠️ CPU has $($Temp)°C - too cold!" $Reply = "⚠️ CPU is too cold at $($Temp)°C!"
} }
"$Reply" "$Reply"
exit 0 # success exit 0 # success

View File

@ -2,7 +2,7 @@
.SYNOPSIS .SYNOPSIS
Determines the exact OS version Determines the exact OS version
.DESCRIPTION .DESCRIPTION
This PowerShell script determines and says the exact operating system version by text-to-speech (TTS). This PowerShell script determines and lists the exact operating system version.
.EXAMPLE .EXAMPLE
PS> ./check-operating-system PS> ./check-operating-system
.LINK .LINK
@ -13,15 +13,15 @@
try { try {
if ($IsLinux) { if ($IsLinux) {
$Reply = (uname -sr) $Details = (uname -sr)
} else { } else {
$OS = Get-WmiObject -class Win32_OperatingSystem $OS = Get-WmiObject -class Win32_OperatingSystem
$OSname = $OS.Caption $OSname = $OS.Caption
$OSarchitecture = $OS.OSArchitecture $OSarchitecture = $OS.OSArchitecture
$OSversion = $OS.Version $OSversion = $OS.Version
$Reply = "$OSname for $OSarchitecture version $OSversion" $Details = "$OSname for $OSarchitecture version $OSversion"
} }
"$Reply" "Running $Details."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,4 +1,4 @@
<# <#
.SYNOPSIS .SYNOPSIS
Check for pending reboots Check for pending reboots
.DESCRIPTION .DESCRIPTION
@ -23,41 +23,41 @@ function Test-RegistryValue { param([parameter(Mandatory=$true)][ValidateNotNull
$Reason = "" $Reason = ""
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") { if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") {
$Reason +="found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'." $Reason += "found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' "
} }
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting") { if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting") {
$Reason += "found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting'." $Reason += "found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting' "
} }
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending") { if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending") {
$Reason += "found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending'." $Reason += "found registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending' "
} }
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts") { if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts") {
$Reason += "found registry key 'HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts'." $Reason += "found registry key 'HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts' "
} }
if (Test-RegistryValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Value "RebootInProgress") { if (Test-RegistryValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Value "RebootInProgress") {
$Reason += "registry key 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' contains 'RebootInProgress'." $Reason += "registry 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' = 'RebootInProgress' "
} }
if (Test-RegistryValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Value "PackagesPending") { if (Test-RegistryValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Value "PackagesPending") {
$Reason += "registry key 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' contains 'PackagesPending'." $Reason += "registry 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' = 'PackagesPending' "
} }
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations") { if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations") {
$Reason += "registry key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' contains 'PendingFileRenameOperations'." $Reason += "registry 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' = 'PendingFileRenameOperations' "
} }
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations2") { if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations2") {
$Reason += "registry key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' contains 'PendingFileRenameOperations2'." $Reason += "registry 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' = 'PendingFileRenameOperations2' "
} }
if (Test-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" -Value "DVDRebootSignal") { if (Test-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" -Value "DVDRebootSignal") {
$Reason += "registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' contains 'DVDRebootSignal'." $Reason += "registry 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' = 'DVDRebootSignal' "
} }
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "JoinDomain") { if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "JoinDomain") {
$Reason += "registry key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' contains 'JoinDomain'." $Reason += "registry 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' = 'JoinDomain' "
} }
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "AvoidSpnSet") { if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "AvoidSpnSet") {
$Reason += "registry key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' contains 'AvoidSpnSet'." $Reason += "registry 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' = 'AvoidSpnSet' "
} }
if ($Reason -eq "") { if ($Reason -eq "") {
"✅ No pending reboot." "✅ No pending reboot."
} else { } else {
"⚠️pending reboot ($Reason)." "⚠️ Pending reboot ($Reason)."
} }
exit 0 # success exit 0 # success

View File

@ -8,7 +8,7 @@
Specifies the hosts to check (separated by comma) Specifies the hosts to check (separated by comma)
.EXAMPLE .EXAMPLE
PS> ./check-ping PS> ./check-ping
Average ping is 36ms (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
@ -36,7 +36,7 @@ try {
$Avg += $Latency $Avg += $Latency
} }
$Avg = $Avg / $Pings.count $Avg = $Avg / $Pings.count
"Average ping is $($Avg)ms ($($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 {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"