PowerShell script reboot check

Today, I received a mail notification that a given server is not available anymore. The error was sent around 6:10 in the morning. The server is a management server not managed by our team.

To decrease the time required if the reboot was caused by Windows updates (which was the reason in the past), I quickly wrote a little PowerShell script to determine the cause.

PS C:\Users\rur> Get-EventLog -LogName System -after (get-date).addhours(-48) | where {($_.EventId -eq 1074) -or ($_.EventId -eq 22)} | select TimeGenerated,EventId,Message | format-table -wrap -autosize

Continue reading