Update check-pending-reboot.ps1

This commit is contained in:
Markus Fleschutz 2022-10-29 17:34:15 +02:00
parent 63860c3d8d
commit a2d2aaa932

View File

@ -23,37 +23,37 @@ 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 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' in registry" $Reason += ", found registry entry: '...\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 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting' in registry" $Reason += ", found registry entry: '...\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 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending' in registry" $Reason += ", found registry entry: '...\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 'HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts' in registry" $Reason += ", found registry entry: '...\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 += ", found 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' with 'RebootInProgress' in registry" $Reason += ", found registry entry: '...\Windows\CurrentVersion\Component Based Servicing' with '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 += ", found 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' with 'PackagesPending' in registry" $Reason += ", found registry entry: '...\Windows\CurrentVersion\Component Based Servicing' with '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 += ", found 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' with 'PendingFileRenameOperations' in registry" # $Reason += ", found registry entry '...\CurrentControlSet\Control\Session Manager' with '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 += ", found 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' with 'PendingFileRenameOperations2' in registry" $Reason += ", found registry entry '...\CurrentControlSet\Control\Session Manager' with '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 += ", found 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' with 'DVDRebootSignal' in registry" $Reason += ", found registry entry '...\Windows\CurrentVersion\RunOnce' with 'DVDRebootSignal'"
} }
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "JoinDomain") { if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "JoinDomain") {
$Reason += ", found 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' with 'JoinDomain' in registry" $Reason += ", found registry entry '...\CurrentControlSet\Services\Netlogon' with 'JoinDomain'"
} }
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "AvoidSpnSet") { if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "AvoidSpnSet") {
$Reason += ", found 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' with 'AvoidSpnSet' in registry" $Reason += ", found registry entry '...\CurrentControlSet\Services\Netlogon' with 'AvoidSpnSet'"
} }
if ($Reason -ne "") { if ($Reason -ne "") {
"⚠️ Pending reboot ($($Reason.substring(2)))." "⚠️ Pending reboot ($($Reason.substring(2)))."