Forum Discussion
Peter_BW
Jan 22, 2021Copper Contributor
Is my server pending reboot?
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 reaso...
- Jan 22, 2021
Something here might help.
How to Find Restart Info Using PowerShell and Windows Event Logs - WhatsUp Gold
Dave Patrick
Jan 22, 2021MVP
Something here might help.
How to Find Restart Info Using PowerShell and Windows Event Logs - WhatsUp Gold
Peter_BW
Jan 22, 2021Copper 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
- Dave PatrickJan 22, 2021MVP
Glad to hear it helps. Please don't forget to mark helpful replies.
- Peter_BWJan 27, 2021Copper Contributor
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.