Skip to content

Instantly share code, notes, and snippets.

@kurtraschke kurtraschke/sleep.ps1
Last active Mar 2, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.