From fa9223b24e7e53aee4e250a4733369d063fa39ea Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Tue, 11 Oct 2022 20:13:04 +0200 Subject: [PATCH] Update check-pending-reboot.ps1 --- Scripts/check-pending-reboot.ps1 | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Scripts/check-pending-reboot.ps1 b/Scripts/check-pending-reboot.ps1 index 79c2d90d..765f33e5 100644 --- a/Scripts/check-pending-reboot.ps1 +++ b/Scripts/check-pending-reboot.ps1 @@ -12,48 +12,48 @@ #> function Test-RegistryValue { param([parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]$Path, [parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()]$Value) - try { - Get-ItemProperty -Path $Path -Name $Value -EA Stop - return $true - } catch { - return $false - } + try { + Get-ItemProperty -Path $Path -Name $Value -EA Stop + return $true + } catch { + return $false + } } $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 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' in registry" } 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 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting' in registry" } 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 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending' in registry" } if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts") { - $Reason += ", found registry key: HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts" + $Reason += ", found 'HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts' in registry" } 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 += ", found 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' with 'RebootInProgress' in registry" } 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 += ", found 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing' with 'PackagesPending' in registry" } if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations") { - $Reason += ", registry key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' contains: PendingFileRenameOperations" + $Reason += ", found 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' with 'PendingFileRenameOperations' in registry" } if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations2") { - $Reason += ", registry key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' contains: PendingFileRenameOperations2" + $Reason += ", found 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' with 'PendingFileRenameOperations2' in registry" } if (Test-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" -Value "DVDRebootSignal") { - $Reason += ", registry key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' contains: DVDRebootSignal" + $Reason += ", found 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' with 'DVDRebootSignal' in registry" } if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "JoinDomain") { - $Reason += ", registry key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' contains: JoinDomain" + $Reason += ", found 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' with 'JoinDomain' in registry" } if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "AvoidSpnSet") { - $Reason += ", registry key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' contains: AvoidSpnSet" + $Reason += ", found 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' with 'AvoidSpnSet' in registry" } if ($Reason -eq "") { "✅ No pending reboot."