What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags

View all Tags

[OPEN] Windows Server Status Reboot Pending



Want this feature implemented, too? Please upvote by clicking Thumbs up!

(Posts as a reply won't be published in this feature request thread. Read Me!)

User Story

As we feel its a basic thing, and really nice to know information for server administrators if thir server is waiting for a reboot after a Windows Update or Software been installed. Even though this should be done automaticly , its not alwayes working as intended.

Details of User Story

We been using this PS script from Microsoft , but as we bought PTRG we would have hoped for a sensor that could do the same:

>----------- #The sample scripts are not supported under any Microsoft 
>standard support #program or service. The sample scripts are provided 
>AS IS without warranty #of any kind. Microsoft further disclaims all 
>implied warranties including, #without limitation, any implied 
>warranties of merchantability or of fitness for #a particular purpose. 
>The entire risk arising out of the use or performance of #the sample 
>scripts and documentation remains with you. In no event shall 
>#Microsoft, its authors, or anyone else involved in the creation, 
>production, or #delivery of the scripts be liable for any damages 
>whatsoever (including, #without limitation, damages for loss of 
>business profits, business interruption, #loss of business information, 
>or other pecuniary loss) arising out of the use #of or inability to use 
>the sample scripts or documentation, even if Microsoft #has been 
>advised of the possibility of such damages
>#requires -version 3.0
>The PowerShell script which can be used to check if the server is pending reboot.
>The PowerShell script which can be used to check if the server is pending reboot.
>.PARAMETER  ComputerName
>Gets the server reboot status on the specified computer.
>C:\PS> C:\Script\FindServerIsPendingReboot.ps1 -ComputerName "WIN-VU0S8","WIN-FJ6FH","WIN-FJDSH","WIN-FG3FH"
>ComputerName  RebootIsPending
>------------  ---------------
>WIN-VU0S8  False
>WIN-FJ6FH  True
>WIN-FG3FH  True
>This command will get the reboot status on the specified remote computers.
>Foreach($cn in $ComputerName)
>#Declare the variable
>$PendingFile = $false
>$AutoUpdate = $false
>$CBS = $false
>$SCCMPending = $false
>#Determine PendingFileRenameOperations exists of not $PendFileKeyPath = 
>"HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\"
>Invoke-Command -ComputerName $cn -ScriptBlock{ Get-ItemProperty -Path 
>$using:PendFileKeyPath -name PendingFileRenameOperations} -ErrorAction 
>SilentlyContinue |` 
>Foreach{If($_.PendingFileRenameOperations){$PendingFile = 
>$true}Else{$PendingFile = $false}}
>#Determine RebootRequired subkey exists or not $AutoUpdateKeyPath = 
>"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update"
>Invoke-Command -ComputerName $cn -ScriptBlock {Test-Path -Path 
>"$using:AutoUpdateKeyPath\RebootRequired"} |` Foreach{If($_ -eq 
>$true){$AutoUpdate = $true}Else{$AutoUpdate = $false}}
>#Determine SCCM 2012 reboot require
>$SCCMReboot = Invoke-CimMethod -Namespace 'Root\ccm\clientSDK' 
>-ClassName 'CCM_ClientUtilities' -ComputerName $cn ` -Name 
>'DetermineIfRebootPending' -ErrorAction SilentlyContinue
>If($SCCMReboot.RebootPending -or $SCCMReboot.IsHardRebootPending) { 
>$SCCMPending = $true } }
>#Determine Component-Based Servicing reboot require #The servicing 
>stack is available on all Windows Vista and Windows Server 2008 installations.
>$CBSKeyPath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\"
>Invoke-Command -ComputerName $cn -ScriptBlock {Test-Path -Path 
>"$using:CBSKeyPath\RebootPending"} |` Foreach{If($_ -eq $true){$CBS = 
>$true}Else{$CBS = $false}}
>If($PendingFile -or $AutoUpdate -or $CBS -or $SCCMPending) { 
>[PSCustomObject]@{ComputerName = $cn;RebootIsPending = $true} } Else { 
>[PSCustomObject]@{ComputerName = $cn;RebootIsPending = $false} } }

Acceptance criteria

  • Registery Check is the most used so if this could be working it would solve most cases.



add-sensor prtg-kbtracker reboot-pending windows-server

Created on Sep 5, 2019 2:22:26 PM

Last change on Sep 9, 2019 11:07:47 AM by  Stephan Linke [Paessler Support]

1 Reply



Hi Hillerod Kommune.

I had the same need as you, and I have ended up with this litle PS script, it does the job for me.

param([string]$computername = "")
$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine","$computername",[Microsoft.Win32.RegistryView]::Registry64 ) 
$key = $baseKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Component Based Servicing") 
$subkeys = $key.GetSubKeyNames() 
Write-Host "Reboot Pending:2"; exit 2 

if($subkeys.Contains("RebootPending")) { 
Write-Host "Reboot Pending:1"; exit 1 } 
else { 
Write-Host "Reboot Pending:0"; exit 0 }

Since it is 64 Bit Powershell It should be started by PSX64 Parametere are like this "-f="pendingreboot.ps1" -p="%host""

Created on Oct 20, 2022 12:06:51 PM

Last change on Oct 21, 2022 6:19:22 AM by  Felix Wiesneth [Paessler Support]

Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.