Score:0

How to identify when a server is preparing to restart for Windows Updates?

cn flag

When a system is working on Windows Updates that require a reboot, at a certain stage it will kick RDP sessions and new RDP sessions will immediately be bounced back. But, I've also seen other (mystery) cases where new RDP sessions are kicked immediately in the same fashion.

What I'm hoping to find is a way to tell via PowerShell (via SSH, remoting, virsh/IPMI console, or ansible) that a host is in this sort of "you can't RDP because we're applying Windows Updates in preparation for a reboot" state.

I've looked at various Windows Update related status objects in PowerShell but I've been unable to find one that can confirm "yes the machine is in this state so your RDP not working is expected".

Bonus points if there's also some way to confirm that progress is truly being made on the work (and that it's not stuck and needing a forced reboot).

in flag
Next time you encounter a direct bounce back I would note the time and later check Windows event log for the noted time what events were recorded. May be you then get a better understanding of the state of the server and how to query or identify this state.
Score:0
in flag

There is a PendingReboot powershell module that will test for that condition. It should help you develop a script that will do what you need.

https://www.powershellgallery.com/packages/PendingReboot/0.9.0.6

This article may help you on your way.

https://lazyadmin.nl/it/how-to-stop-automatic-restart-win-10-after-installing-updates/

cn flag
Thanks but that module seems to tell you that a pending reboot is required, not that one is actually in-progress. For example it says that a reboot is pending when the system is just sitting there waiting for reboot and also while it's working on rebooting (e.g. the time that it kicks you from RDP if you try to connect).
cn flag
@DanielJennings: a restart should only be "in progress" for a few seconds before the pending status is changed. Additionally, if a restart is pending, remote connections (such as PowerShell) may also be unreliable.
Mr Cholmondley Warner avatar
in flag
@DanielJennings: I think you would need to query the RD Connection Broker for the availability of the remote desktop to get this information (availability, not that the computer is updating, don't know how to query that either!), as it is probably the connection broker that is kicking the session when the remote host is unavailable. Not sure quite what you would need to query for in your circumstances. See if this helps you: https://docs.microsoft.com/en-us/powershell/module/remotedesktop/get-rdvirtualdesktop?view=windowsserver2016-ps
cn flag
@GregAskew With the most recent round of Window Server 2019 LTSC updates we're seeing it frequently doing something for ten+ minutes where RDP is unavailable but SSH remoting works fine. Haven't had graphical terminal access yet to an affected machine to know what UI is being presented there, but it's clearly in some sort of preparing-to-reboot state that rejects RDP. Possibly updates to the RDP Server were included in a recent security patch or something?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.