Skip to content

Instantly share code, notes, and snippets.

@kurtraschke
Last active March 2, 2016 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurtraschke/16bb99be890623c50b7f to your computer and use it in GitHub Desktop.
Save kurtraschke/16bb99be890623c50b7f to your computer and use it in GitHub Desktop.
PowerShell script to summarize a Windows PC's sleep history
$filter = @{LogName='System';
ProviderName='Microsoft-Windows-Power-Troubleshooter';
ID=1}
$namespaces = @{"event"="http://schemas.microsoft.com/win/2004/08/events/event"}
Get-WinEvent -FilterHashtable $filter | % {
$obj = New-Object PSObject
[xml]$_.ToXml() | Select-Xml -Namespace $namespaces "/event:Event/event:EventData/event:Data" | % {
Add-Member -InputObject $obj -MemberType NoteProperty -Name $_.Node.Name -Value $_.Node.'#text'
}
Add-Member -InputObject $obj -MemberType NoteProperty -Name "Message" -Value $_.Message
$obj
} | Out-GridView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment