SOLVED

Is my server pending reboot?

%3CLINGO-SUB%20id%3D%22lingo-sub-2087115%22%20slang%3D%22en-US%22%3EIs%20my%20server%20pending%20reboot%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2087115%22%20slang%3D%22en-US%22%3E%3CP%3EI%20wonder%20if%20anyone%20has%20any%20ideas%20on%20finding%2C%20using%20powershell%2C%20if%20a%20server%20is%20planning%20on%20rebooting%20anytime%20soon%3F%3C%2FP%3E%3CP%3EI%20can%20find%20out%20if%20a%20reboot%20is%20due%20for%20windows%20updates%20and%20a%20few%20other%20possible%20reasons%2C%20using%20powershell%20but%20if%20a%20reboot%20is%20waiting%20from%20running%20shutdown%20-r%20-t%20nnnnn%20then%20none%20of%20the%20places%20I%20know%20to%20look%20are%20helpful.%20Even%20Windows%20Admin%20Centre%20does%20not%20seem%20to%20know%20the%20server%20has%20a%20reboot%20pending.%20I%20have%20looked%20in%20Event%20viewer%20for%20a%20system%20log%20event%20ID13%20but%20that%20may%20or%20may%20not%20tell%20me%20anything%20about%20an%20upcoming%20reboot.%3C%2FP%3E%3CP%3EA%20shutdown%20-a%20knows%20if%20a%20reboot%20is%20pending%20or%20not%20(it%20errors%20if%20not)%20but%20I%20can't%20find%20out%20where%20to%20look%20to%20find%20this%20information%20myself.%3C%2FP%3E%3CP%3EAny%20Ideas%20please%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2087115%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2087165%22%20slang%3D%22en-US%22%3ERe%3A%20Is%20my%20server%20pending%20reboot%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2087165%22%20slang%3D%22en-US%22%3E%3CP%3ESomething%20here%20might%20help.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.whatsupgold.com%2Fblog%2Fhow-to-find-restart-info-for-machines-on-your-network-using-powershell-and-windows-event-logs%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHow%20to%20Find%20Restart%20Info%20Using%20PowerShell%20and%20Windows%20Event%20Logs%20-%20WhatsUp%20Gold%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2087349%22%20slang%3D%22en-US%22%3ERe%3A%20Is%20my%20server%20pending%20reboot%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2087349%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F51719%22%20target%3D%22_blank%22%3E%40Dave%20Patrick%3C%2FA%3E%26nbsp%3BThanks%20that%20does%20help%20-%20I%20was%20using%20get%20get-eventlog%20to%20try%20and%20look%20at%20event%20ID13%20and%20that%20was%20really%20not%20helpful.%3C%2FP%3E%3CP%3EGet-WinEvent%20is%20much%20more%20useful%20and%20actually%20returns%20the%20date%20and%20time%20of%20the%20scheduled%20reboot%2C%20and%20the%20reason.%26nbsp%3B%3C%2FP%3E%3CP%3EMany%20thanks%20for%20that%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I wonder if anyone has any ideas on finding, using powershell, if a server is planning on rebooting anytime soon?

I can find out if a reboot is due for windows updates and a few other possible reasons, using powershell but if a reboot is waiting from running shutdown -r -t nnnnn then none of the places I know to look are helpful. Even Windows Admin Centre does not seem to know the server has a reboot pending. I have looked in Event viewer for a system log event ID13 but that may or may not tell me anything about an upcoming reboot.

A shutdown -a knows if a reboot is pending or not (it errors if not) but I can't find out where to look to find this information myself.

Any Ideas please?

4 Replies
best response confirmed by Peter_BW (New Contributor)

@Dave Patrick Thanks that does help - I was using get get-eventlog to try and look at event ID13 and that was really not helpful.

Get-WinEvent is much more useful and actually returns the date and time of the scheduled reboot, and the reason. 

Many thanks for that

Glad to hear it helps. Please don't forget to mark helpful replies.

 

 

 

So, for anyone else having this problem:

I could find nothing in registry that helped specifically for shutdown.exe

This https://www.powershellgallery.com/packages/PendingReboot/0.9.0.6 identified some reboot reasons I did not know about so I used this rather than my original code.

I then looked at the last event log entry for 1074

Get-WinEvent -ComputerName $computername -FilterHashtable @{logname = 'System'; id = 1074} -MaxEvents 1

by comparing the TimeCreated property of that result with the last boot time of the computer I could see if the event was historical or planned.

If planned, I then compared the TimeCreated property of event 1074 with 1075 to see it a shutdown -a had been used to cancel the reboot.