Server Manager in Windows Server 2008 R2 occasionally displays the warning: Console cannot refresh until computer is restarted
, and in this state you cannot use Server Manager for adding or removing roles/features.
It is clear that this is related with roles/updates install processes which need a reboot for completion (e.g. to replace file in use or something similar). How can I determine the cause of this status more precisely?
Sometimes, in multi-user (or should I say multi-admin) environments, you don't know which changes were made by your colleagues and it is always better to know why you are going to reboot your server.
This isn't really possible, at least not with the level of detail that you want, because Windows simply doesn't record that level of detail on why a reboot is needed. Also, as I said in my comment above, this seems to point at some pretty serious underlying issues in your environment that you should address - lack of change controls and bad administration practices.
Having said that, Windows tracks the pending reboot status in the registry, and there's a two-part blog series on Technet's Scripting Guy blog about how to use PowerShell to determine this status, which conveniently shows you where to look manually for these flags as well. (They're in the registry, surprise, surprise).
From Part I:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager
, if there is a value namedPendingFileRenameOperations
, it will contain a list of files that need to be renamed on reboot.HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update
, if there is a value namedRebootRequired
, a reboot is pending.HKLM\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending
System Center Configuration Manager 2012 must be installed on the client. When it’s installed, the ‘ROOT\ccm\ClientSDK’ WMI class will be available. This class has a method called DetermineIfRebootPending.
If you prefer to just grab the PowerShell script, that's here, in Part II.
https://blogs.technet.microsoft.com/heyscriptingguy/2013/06/11/determine-pending-reboot-statuspowershell-style-part-2/
here is the updated link and script
https://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542