14 November 2023

Last reboot reason using PowerShell

 Use this PowerShell command, to obtain last restart reasons:

$x = foreach ($e in (Get-WinEvent -FilterHashtable @{logname = 'System'; id = 1074 })) {

    [PSCustomObject]@{

        Time        = $e.TimeCreated

        Type        = $e.Properties.Value[4]

        User        = $e.Properties.Value[6]

        Process     = $e.Properties.Value[0]

        Reason      = $e.Properties.Value[2]

        Description = $e.Properties.Value[5]

    }

}

$x | Out-GridView