2

I'm looking for either a PowerShell script or command that allows me to get the active power plan's time until sleep.

In the below example, I know from the previous screen that "Balanced" is the Active Power plan. Selecting that, gets to this screen where I can see this info.

Sleep settings

I've currently tried places in both WMI and the registry, but everything is set to GUIDs and you have to pull the Active Powerplan first. I have also tried powercfg and it various commands.

Do I have to query the active powerplan with powercfg, parse that response, so I only get the GUID, and then query using that result in the registry or WMI?

Looking for some guidance or even some code.

Sjoerd
  • 74,049
  • 16
  • 131
  • 175
dzampino
  • 123
  • 4
  • 1
    Possible duplicate of [How to READ the auto sleep time of pc from powercfg.exe (batch)](http://stackoverflow.com/questions/39606633/how-to-read-the-auto-sleep-time-of-pc-from-powercfg-exe-batch) – geisterfurz007 Sep 22 '16 at 14:13
  • 1
    Possible duplicate of [How do I read individual PowerCfg settings?](http://stackoverflow.com/questions/28049663/how-do-i-read-individual-powercfg-settings) – Paul Sweatte Sep 22 '16 at 15:36

1 Answers1

0

Use powershell command to find out current and active Power plan.

gwmi -Namespace Root\CIMV2\power -Class win32_powerplan  -Filter isActive=’true’ | select ElementName , Description, InstanceID

and then use instanceID to query powercfg

powercfg /QUERY <InstanceID>
Amit Shakya
  • 1,396
  • 12
  • 27