Skip to content

Instantly share code, notes, and snippets.

@sub314xxl
Created April 7, 2024 12:25
Show Gist options
  • Save sub314xxl/59af788fe636ba026dfeba7aaf1ca11a to your computer and use it in GitHub Desktop.
Save sub314xxl/59af788fe636ba026dfeba7aaf1ca11a to your computer and use it in GitHub Desktop.
PoSH: get boot process duration
Get-WinEvent -FilterHashtable @{LogName="Microsoft-Windows-Diagnostics-Performance/Operational"; Id=100} -MaxEvents 10 | ForEach-Object {
# convert the event to XML and grab the Event node
$eventXml = ([xml]$_.ToXml()).Event
# output
[PSCustomObject]@{
'Computer' = $eventXml.System.Computer
'BootTime' = [int64]($eventXml.EventData.Data | Where-Object {$_.Name -eq 'BootTime'}).InnerXml
'BootFinished' = [datetime]($eventXml.EventData.Data | Where-Object {$_.Name -eq 'BootEndTime'}).InnerXml
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment