1

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.

3
  • That route seems fine. powercfg has a flag /GETACTIVESCHEME which will help, then you need to isolate the GUID. You can use this to reduce the output of powercfg /QUERY. You can also find the active plan with Get-WmiObject -Class win32_powerplan -Namespace root\cimv2\power -Filter "isActive='true'"
    – root
    Sep 22, 2016 at 14:25
  • Just to clarify, you want to retrieve the power plan setting, not the actual current time remaining until sleep? Also, you want to retrieve and store the value in a form you can use programmatically, not just display the setting?
    – fixer1234
    Sep 22, 2016 at 17:46
  • @fixer1234 Correct on both accounts
    – dzampino
    Sep 22, 2016 at 18:02

0

You must log in to answer this question.

Browse other questions tagged .