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)
}
if ($Temp -gt 80) {
$Reply = "⚠️ CPU has $($Temp)°C - too hot!"
$Reply = "⚠️ CPU is too hot at $($Temp)°C!"
} elseif ($Temp -gt 50) {
$Reply = "✅ CPU has $($Temp)°C - hot."
$Reply = "✅ CPU is $($Temp)°C hot."
} elseif ($Temp -gt 0) {
$Reply = "✅ CPU has $($Temp)°C - warm."
$Reply = "✅ CPU is $($Temp)°C warm."
} elseif ($Temp -gt -20) {
$Reply = "✅ CPU has $($Temp)°C - cold."
$Reply = "✅ CPU is $($Temp)°C cold."
} else {
$Reply = "⚠️ CPU has $($Temp)°C - too cold!"
$Reply = "⚠️ CPU is too cold at $($Temp)°C!"
}
"$Reply"
exit 0 # success

View File

@ -2,7 +2,7 @@
.SYNOPSIS
Determines the exact OS version
.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
PS> ./check-operating-system
.LINK
@ -13,15 +13,15 @@
try {
if ($IsLinux) {
$Reply = (uname -sr)
$Details = (uname -sr)
} else {
$OS = Get-WmiObject -class Win32_OperatingSystem
$OSname = $OS.Caption
$OSarchitecture = $OS.OSArchitecture
$OSversion = $OS.Version
$Reply = "$OSname for $OSarchitecture version $OSversion"
$Details = "$OSname for $OSarchitecture version $OSversion"
}
"$Reply"
"Running $Details."
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,4 +1,4 @@
<#
<#
.SYNOPSIS
Check for pending reboots
.DESCRIPTION
@ -23,41 +23,41 @@ function Test-RegistryValue { param([parameter(Mandatory=$true)][ValidateNotNull
$Reason = ""
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") {
$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") {
$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") {
$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") {
$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") {
$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") {
$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") {
$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") {
$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") {
$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") {
$Reason += "registry key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' contains 'AvoidSpnSet'."
$Reason += "registry 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' = 'AvoidSpnSet' "
}
if ($Reason -eq "") {
"✅ No pending reboot."
} else {
"⚠️pending reboot ($Reason)."
"⚠️ Pending reboot ($Reason)."
}
exit 0 # success

View File

@ -8,7 +8,7 @@
Specifies the hosts to check (separated by comma)
.EXAMPLE
PS> ./check-ping
Average ping is 36ms (13ms min, 109ms max)
Ping is 25ms average (13ms min, 109ms max).
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -36,7 +36,7 @@ try {
$Avg += $Latency
}
$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
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"