PowerShell - Check Last System Reboot/Shutdown Reason

PowerShell - Check Last System Reboot/Shutdown Reason
Photo by Clément Hélardot / Unsplash

You might encounter situations where you PC may have shutdown or rebooted when trying to wake up from sleep or other reasons. You can use PowerShell to pull windows event logs to look for clues as to why that may have happened. You can also use this to pull any other system logs.

Get-WinEvent -MaxEvents 5 -FilterHashtable @{ LogName = 'System'; Id = 41, 1074, 6006, 6605, 6008; } | Format-List Id, LevelDisplayName, TimeCreated, Message

Use -MaxEvents  to suit your requirements.