views:

807

answers:

1

Hello gang, I'm trying to find out the last time a computer came out of standby/hibernate. I know I could get this by watching Win32_PowerManagementEvent, but that doesn't work in this instance as I need something I can poll - any ideas? It doesn't have to be WMI, I'm just assuming that's the place it would be.

Thanks!

A: 

Actually, as it usually happens, I figured this out as soon as I posted it.

So, to watch for when a computer comes out of standby, which is EventType 7 in Win32_PowerManagementEvent I used Powershell.

Register-WmiEvent -query "Select * From Win32_PowerManagementEvent where EventType=7" -messagedata "Power Management Resume" -sourceidentifier "Resume"

Then I went into and came back out of standby, and did Get-PSEvent, which showed my event I created. I could have just used -action to assign a scriptblock to run when that event occurs, but I was looking for something to poll.