Skip to content

Instantly share code, notes, and snippets.

@hyperreality
Created January 2, 2026 17:14
Show Gist options
  • Select an option

  • Save hyperreality/f88b2674324387a498c5f20361ad2085 to your computer and use it in GitHub Desktop.

Select an option

Save hyperreality/f88b2674324387a498c5f20361ad2085 to your computer and use it in GitHub Desktop.
Get Windows reboot reason
$today = Get-Date
$startDay = $today.AddDays(-5)
$eventIds=(6005,6006,6008,6009,1074,1076,12,13,43,109)
$systEvents=Get-WinEvent -LogName System
$rebootEvents=$systEvents| Where-Object {$_.TimeCreated -gt $startDay} | Where-Object {$_.Id -in $eventIds}
format-table TimeCreated,Id,Message -AutoSize -wrap -InputObject $rebootEvents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment