In Windows, the registry is a database of settings and options that programs use to change or configure your computer. When it needs to be updated in order for this configuration change or option to take effect, you may need a manual reboot. If there’s no pending reboot scheduled on your PC, the easiest way to check for one is by looking at the power status indicator located next to your system clock in Task Manager – click “More Details” under Power Options if necessary.
The “pending reboot registry windows 10” is a tutorial that will teach you how to check for a pending reboot in the Windows Registry.
It’s normal for Windows to need a reboot after installing software, updating, or making setting changes. Many OS operations need a reboot from time to time. When a reboot is about to happen, Windows adds several registry variables to indicate it. You’ll learn how to check for a pending reboot and create a PowerShell script to automate the process in this blog article.
Windows should be restarted.
When you’re on the console, you’ll get a popup window or indication that a reboot is about to happen, as illustrated below.
You may restart Windows and be done with it after receiving that message. But what if you can’t reboot a system as soon as it requires it? What if you’ve just finished installing updates on a live server that can’t be restarted right now?
Message about a pending Windows reboot
The reboot will have to wait.
After some time has passed, the reboot may be completely forgotten! Many servers or workstations will need to be restarted by the time you recognize it, but which ones?
The Registry has Pending Reboot Flags.
The term “waiting reboot” is used in a variety of contexts. To view the values and criteria, scroll to the right. If any of the requirements in this table are true, a Windows machine will need to be rebooted.
Key | Value | Condition |
HKLM:SOFTWAREMicrosoftUpdates | UpdateExeVolatile | Anything that isn’t 0 is a value. |
HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager) (HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager)) | PendingFileRenameOperations | There is worth. |
HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager) (HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager)) | PendingFileRenameOperations2 | There is worth. |
HKLM:SOFTWARE MicrosoftWindowsCurrentVersion WindowsUpdate Automated Update RebootRequired | NA | there is a crucial |
HKLM:SOFTWAREMicrosoftWindowsCurrentVersion WindowsUpdateServicesPending | NA | Exist any GUID subkeys? |
HKLM:SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate Automated Update PostRebootReporting | NA | there is a crucial |
HKLM:SOFTWAREMicrosoftWindowsCurrentVersionRunOnce | DVDRebootSignal | There is worth. |
HKLM:Software Servicing based on MicrosoftWindowsCurrentVersionComponents RebootPending | NA | there is a crucial |
HKLM:Software Servicing based on MicrosoftWindowsCurrentVersionComponents RebootInProgress | NA | there is a crucial |
HKLM:Software MicrosoftWindowsCurrentVersionComponent Based ServicingPackagesPending MicrosoftWindowsCurrentVersionComponent Based ServicingPackagesPending | NA | there is a crucial |
HKLM:SOFTWAREMicrosoftServerManagerCurrentRebootAttempts | NA | there is a crucial |
HKLM:SYSTEMCurrentControlSetServicesNetlogon | JoinDomain | There is worth. |
HKLM:SYSTEMCurrentControlSetServicesNetlogon | AvoidSpnSet | There is worth. |
HKLM:SYSTEMCurrentControlSetControlComputerNameActiveComputerName | ComputerName | Value ComputerName in HKLM:SYSTEMCurrentControlSetControlComputerNameComputerNameComputerNameComputerNameComputerNameComputerNameComputerNameComputerNameComputerNameComputerNameComput |
These methods may also be visible in WMI if you have the Microsoft System Center Configuration Manager (SCCM) client installed.
Namespace | Class | Property | Value | Product | Notes |
ROOTccmClientSDK | CCM ClientUtilities | DetermineifRebootPending | RebootPending | SCCM | ReturnValue must be zero, and this value must not be null. |
ROOTccmClientSDK | CCM ClientUtilities | DetermineifRebootPending | IsHardRebootPending | SCCM | ReturnValue must be zero, and this value must not be null. |
There are many other methods to examine registry settings once you know how to check for a pending reboot. You might use regedit.exe to go through each registry key by hand.
Manually checking regedit
Manually verifying the register is possible, but we’re just human. What if you forget to check one or more registry paths, or if you don’t know which ones to check? There’s a far more efficient method to do this. You may automate this process by writing a script or a function. PowerShell is what I prefer, therefore that’s what I’ll use.
You may query one or all computers in our domain or manually supply the server names to determine whether they are due for a reboot using a PowerShell script. You may then decide whether to reboot them right away or add them to a list to reboot later. It’s all up to you.
To utilize my PowerShell technique, make sure PowerShell Remoting is enabled and accessible on your servers.
Pending Reboot is being tested (The Easy Way)
I’ve made it simple for you if you don’t want to learn how to check these registry entries and construct a program like this in PowerShell. Simply put Install-Script Test-PendingReboot into your PowerShell console. Install-Script will save my PowerShell script to C:Program FilesWindowsPowerShellScripts from the PowerShell Gallery. Then, as indicated below, execute the script.
PS51> Test-PendingReboot.ps1 -ComputerName localhost ComputerName IsPendingReboot ———— ————— localhost False
The ComputerName argument allows you to specify as many servers as you desire. The script will return True or False, as well as the name of the server.
This utility will do a check on all of the registry keys listed in the table above.
If you find any criteria I’ve missed or any errors I’ve made, please submit a pull request on GitHub to remedy them.
Continue reading if you want to learn how to make a tool like this.
To begin, you’ll need to identify all of the machines on which you’d want to do a reboot test. There are a variety of methods to do this, but for the sake of this tutorial, I’ll use an array to define them manually.
$servers = ‘SRV1′,’SRV2′,’SRV3′,’SRV4′,’SRV5′,’SRV6′,’SRV7’,’SRV8
To iterate through each of them, use a foreach loop.
foreach ($computer in $ComputerName) $ComputerName $ComputerName $ComputerName $ComputerName $Comput
Next, I propose validating each registry key and value condition inside a separate PSSession using PowerShell Remoting. For each server, create a PSSession.
$session = New-PSSession foreach ($computer in $ComputerName)
After you’ve established a PSSession, you’ll need to execute the checks.
Because you’ll be executing a variety of tests with the same code, such as:
- Testing if a registry there is a crucial
- Testing if a registry There is worth.
- Ensure that a registry value isn’t null.
For each of these tests, I propose writing simple functions. Instead of repeating code, you may use this to call a function. As demonstrated below, the Test-PendingReboot script combines all of these auxiliary functions into a single scriptblock.
[OutputType(‘bool’)] function Test-RegistryKey [CmdletBinding()] param ([Mandatory Parameter)]) [ValidateNotNullOrEmpty()] $ErrorActionPreference = ‘Stop’ if (Get-Item -Path) if (Get-Item -Path) if (Get-Item -Path) if (Get-Item -Path) if (Get- $true -ErrorAction Ignore) $Key -ErrorAction Ignore) $true -ErrorAction Ignore) $true -ErrorAction [OutputType(‘bool’)] function Test-RegistryValue [CmdletBinding()] param ([Mandatory Parameter)]) [ValidateNotNullOrEmpty()] [string]$Key, [Mandatory)] [string]$Key, [string]$Key, [string]$Key, [string]$Key, [string] [ValidateNotNullOrEmpty()] [string] $ErrorActionPreference = ‘Stop’ if (Get-ItemProperty -Path) if (Get-ItemProperty -Path) if (Get-ItemProperty -Path) if (Get-ItemProperty $true $Key -Name $Value -ErrorAction Ignore) $Key -Name $Value -ErrorAction Ignore) [OutputType(‘bool’)] function Test-RegistryValueNotNull [CmdletBinding()] param ([Mandatory Parameter)]) [ValidateNotNullOrEmpty()] [string]$Key, [Mandatory)] [string]$Key, [string]$Key, [string]$Key, [string]$Key, [string] [ValidateNotNullOrEmpty()] $ErrorActionPreference = ‘Stop’ if (($regVal = Get-ItemProperty -Path $regVal = Get-ItemProperty -Path $regVal = Get-ItemProperty -Path $regVal = Get-ItemProperty -Path $regVal = $Key -Name $Value -ErrorAction Ignore) -and $regVal.($Value)) -and $regVal.($Value)) -and $regVal.($Value)) -and $regVal.($Value)) -and $regVal.($Value))
Define each condition inside the same scriptblock, referencing the auxiliary functions you just defined.
$tests = @( { Test-RegistryKey -Key ‘HKLM:Software Servicing based on MicrosoftWindowsCurrentVersionComponents RebootPending’ } { Test-RegistryKey -Key ‘HKLM:Software Servicing based on MicrosoftWindowsCurrentVersionComponents RebootInProgress’ } { Test-RegistryKey -Key ‘HKLM:SOFTWARE MicrosoftWindowsCurrentVersion WindowsUpdate Automated Update RebootRequired’ } { Test-RegistryKey -Key ‘HKLM:Software MicrosoftWindowsCurrentVersionComponent Based ServicingPackagesPending MicrosoftWindowsCurrentVersionComponent Based ServicingPackagesPending’ } { Test-RegistryKey -Key ‘HKLM:SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate Automated Update PostRebootReporting’ } { Test-RegistryValueNotNull -Key ‘HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager) (HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager))’ -Value ‘PendingFileRenameOperations’ } { Test-RegistryValueNotNull -Key ‘HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager) (HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager))’ -Value ‘PendingFileRenameOperations2’ } { # Added test to check first if there is a crucial, using “ErrorAction ignore” will incorrectly return $true ‘HKLM:SOFTWAREMicrosoftUpdates’ | Where-Object { test-path $_ -PathType Container } | ForEach-Object { (Get-ItemProperty -Path $_ -Name ‘UpdateExeVolatile’ -ErrorAction Ignore | Select-Object -ExpandProperty UpdateExeVolatile) -ne 0 } } { Test-RegistryValue -Key ‘HKLM:SOFTWAREMicrosoftWindowsCurrentVersionRunOnce’ -Value ‘DVDRebootSignal’ } { Test-RegistryKey -Key ‘HKLM:SOFTWAREMicrosoftServerManagerCurrentRebootAttemps’ } { Test-RegistryValue -Key ‘HKLM:SYSTEMCurrentControlSetServicesNetlogon’ -Value ‘JoinDomain’ } { Test-RegistryValue -Key ‘HKLM:SYSTEMCurrentControlSetServicesNetlogon’ -Value ‘AvoidSpnSet’ } { # Added test to check first if keys exists, if not each group will return $Null # May need to evaluate what it means if one or both of these keys do not exist ( ‘HKLM:SYSTEMCurrentControlSetControlComputerNameActiveComputerName’ | Where-Object { test-path $_ } | %{ (Get-ItemProperty -Path $_ ).ComputerName } ) -ne ( ‘HKLM:SYSTEMCurrentControlSetControlComputerNameComputerName’ | Where-Object { Test-Path $_ } | %{ (Get-ItemProperty -Path $_ ).ComputerName } ) } { # Added test to check first if there is a crucial ‘HKLM:SOFTWAREMicrosoftWindowsCurrentVersion WindowsUpdateServicesPending’ | Where-Object { (Test-Path $_) -and (Get-ChildItem -Path $_) } | ForEach-Object { $true } } )
Within your $servers foreach loop, you can now build a foreach loop that reads and performs each test.
foreach ($test in $tests) { if (& $test) { $true break } }
When you execute the code, you’ll get something like this:
IsPendingRebootComputerName —————————————————————————————————————————— Server1 is false, but Server2 is correct.
You may get this result by making sure the foreach loop only returns one item per server. You should be aware that if any of the registry settings are present, the server will be rebooted. Knowing this, you must return True if any of the values are present, and False if none are present.
Put everything together in a script, and it should look something like this (with some minor additions like Credential).
[CmdletBinding()] param( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string[]]$ComputerName, [Parameter()] [ValidateNotNullOrEmpty()] [pscredential]$Credential ) $ErrorActionPreference = ‘Stop’ $scriptBlock = { $VerbosePreference = $using:VerbosePreference [OutputType(‘bool’)] function Test-RegistryKey [CmdletBinding()] param ([Mandatory Parameter)]) [ValidateNotNullOrEmpty()] $ErrorActionPreference = ‘Stop’ if (Get-Item -Path) if (Get-Item -Path) if (Get-Item -Path) if (Get-Item -Path) if (Get- $true -ErrorAction Ignore) $Key -ErrorAction Ignore) $true -ErrorAction Ignore) $true -ErrorAction [OutputType(‘bool’)] function Test-RegistryValue [CmdletBinding()] param ([Mandatory Parameter)]) [ValidateNotNullOrEmpty()] [string]$Key, [Mandatory)] [string]$Key, [string]$Key, [string]$Key, [string]$Key, [string] [ValidateNotNullOrEmpty()] [string] $ErrorActionPreference = ‘Stop’ if (Get-ItemProperty -Path) if (Get-ItemProperty -Path) if (Get-ItemProperty -Path) if (Get-ItemProperty $true $Key -Name $Value -ErrorAction Ignore) $Key -Name $Value -ErrorAction Ignore) [OutputType(‘bool’)] function Test-RegistryValueNotNull [CmdletBinding()] param ([Mandatory Parameter)]) [ValidateNotNullOrEmpty()] [string]$Key, [Mandatory)] [string]$Key, [string]$Key, [string]$Key, [string]$Key, [string] [ValidateNotNullOrEmpty()] $ErrorActionPreference = ‘Stop’ if (($regVal = Get-ItemProperty -Path $regVal = Get-ItemProperty -Path $regVal = Get-ItemProperty -Path $regVal = Get-ItemProperty -Path $regVal = $Key -Name $Value -ErrorAction Ignore) -and $regVal.($Value)) -and $regVal.($Value)) -and $regVal.($Value)) -and $regVal.($Value)) -and $regVal.($Value)) # Added “test-path” to each test that did not leverage a custom function from above since # an exception is thrown when Get-ItemProperty or Get-ChildItem are passed a nonexistant key path $tests = @( { Test-RegistryKey -Key ‘HKLM:Software Servicing based on MicrosoftWindowsCurrentVersionComponents RebootPending’ } { Test-RegistryKey -Key ‘HKLM:Software Servicing based on MicrosoftWindowsCurrentVersionComponents RebootInProgress’ } { Test-RegistryKey -Key ‘HKLM:SOFTWARE MicrosoftWindowsCurrentVersion WindowsUpdate Automated Update RebootRequired’ } { Test-RegistryKey -Key ‘HKLM:Software MicrosoftWindowsCurrentVersionComponent Based ServicingPackagesPending MicrosoftWindowsCurrentVersionComponent Based ServicingPackagesPending’ } { Test-RegistryKey -Key ‘HKLM:SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate Automated Update PostRebootReporting’ } { Test-RegistryValueNotNull -Key ‘HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager) (HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager))’ -Value ‘PendingFileRenameOperations’ } { Test-RegistryValueNotNull -Key ‘HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager) (HKLM:SYSTEMCurrentControlSetControlSession Manager (HKLM:SYSTEMCurrentControlSetControlSession Manager))’ -Value ‘PendingFileRenameOperations2’ } { # Added test to check first if there is a crucial, using “ErrorAction ignore” will incorrectly return $true ‘HKLM:SOFTWAREMicrosoftUpdates’ | Where-Object { test-path $_ -PathType Container } | ForEach-Object { (Get-ItemProperty -Path $_ -Name ‘UpdateExeVolatile’ | Select-Object -ExpandProperty UpdateExeVolatile) -ne 0 } } { Test-RegistryValue -Key ‘HKLM:SOFTWAREMicrosoftWindowsCurrentVersionRunOnce’ -Value ‘DVDRebootSignal’ } { Test-RegistryKey -Key ‘HKLM:SOFTWAREMicrosoftServerManagerCurrentRebootAttemps’ } { Test-RegistryValue -Key ‘HKLM:SYSTEMCurrentControlSetServicesNetlogon’ -Value ‘JoinDomain’ } { Test-RegistryValue -Key ‘HKLM:SYSTEMCurrentControlSetServicesNetlogon’ -Value ‘AvoidSpnSet’ } { # Added test to check first if keys exists, if not each group will return $Null # May need to evaluate what it means if one or both of these keys do not exist ( ‘HKLM:SYSTEMCurrentControlSetControlComputerNameActiveComputerName’ | Where-Object { test-path $_ } | %{ (Get-ItemProperty -Path $_ ).ComputerName } ) -ne ( ‘HKLM:SYSTEMCurrentControlSetControlComputerNameComputerName’ | Where-Object { Test-Path $_ } | %{ (Get-ItemProperty -Path $_ ).ComputerName } ) } { # Added test to check first if there is a crucial ‘HKLM:SOFTWAREMicrosoftWindowsCurrentVersion WindowsUpdateServicesPending’ | Where-Object { (Test-Path $_) -and (Get-ChildItem -Path $_) } | ForEach-Object { $true } } ) foreach ($test in $tests) { Write-Verbose “Running scriptblock: [$($test.ToString())]” if (& $test) { $true break } } } foreach ($computer in $ComputerName) { try { $connParams = @{ ‘ComputerName’ = $computer } if ($PSBoundParameters.ContainsKey(‘Credential’)) { $connParams.Credential = $Credential } $output = @{ ComputerName = $computer IsPendingReboot = $false } $psRemotingSession = New-PSSession @connParams if (-not ($output.IsPendingReboot = Invoke-Command -Session $psRemotingSession -ScriptBlock $scriptBlock)) { $output.IsPendingReboot = $false } [pscustomobject]$output } catch { Write-Error -Message $_.Exception.Message } finally { if (Get-Variable -Name ‘psRemotingSession’ -ErrorAction Ignore) { $psRemotingSession | Remove-PSSession } } }
You may now carry it out as follows:
PS51> .Test-PendingReboot.ps1 -Server SRV1,SRV2,SRV3,etc
Summary
You should now be able to test pending reboots across all Windows servers quickly. As you can see, PowerShell allows you to condense a lot of time-consuming tasks into a single script. This script enables you to easily check for pending reboots on several servers at the same time.
Please let me know if you see any more signs that a reboot is imminent.
The “pending reboot registry key” is a command-line tool that can be used to check for pending reboots in the registry. This process may take up to 10 minutes.
Frequently Asked Questions
Related Tags
- clear pending reboot windows 10
- check pending reboot command line
- check pending reboot powershell
- windows update pending reboot registry key
- wmi check pending reboot -powershell