CIM to Get/Set computer Sleep settings

This topic contains 5 replies, has 4 voices, and was last updated by  js 3 months, 3 weeks ago.

  • Author
    Posts
  • #76433

    Kevin Greer
    Participant

    To change the power settings on a remote computer to never sleep I run the below commands. I would like to be able to Get and Set the standby timeout and hibernate timeout values. I decided to dig into the CIM namespace ROOT\cimv2\power. I'm not having any luck with finding a solution to using CIM to Get and Set these values. The reason I want to report (Get) the standby and hibernate values is so I know if I have to Set them or not.

    Is there a CIM way to do the below and also report on the settings?

    Invoke-Command -ComputerName $ComputerName -ScriptBlock {C:\Windows\system32\powercfg.exe -change -standby-timeout-ac 0}
    Invoke-Command -ComputerName $ComputerName -ScriptBlock {C:\Windows\system32\powercfg.exe -change -hibernate-timeout-ac 0}
    
  • #76435

    Don Jones
    Keymaster

    I'd thought you could only deal with Power Plans (https://blogs.technet.microsoft.com/heyscriptingguy/2012/11/27/use-powershell-and-wmi-or-cim-to-view-and-to-set-power-plans/), not individual settings. Microsoft kind of made a push for not managing individual settings, but instead bundling them into Plans. That's how the GUI deals with them.

  • #76438

    Richard Siddaway
    Moderator

    I remember digging into this when I wrote PowerShell and WMI and you have to work at the plan level

  • #76439

    Kevin Greer
    Participant

    I read that scripting guy article. I see how you can change the power plan. So I would want to change the power plan to high performance to achieve the same result? Except it would be whatever custom settings are configured behind those plans, right.

  • #76459

    js
    Participant

    You can narrow it down a bit like this using aliases:

    powercfg /query sub_balanced sub_sleep standbyidle
    powercfg /query sub_balanced sub_sleep hibernateidle
    

    There might be a powershell module that just runs powercfg.

    • #76502

      js
      Participant

      scheme_balanced not sub_balanced

      C:\>powercfg /query scheme_balanced sub_sleep standbyidle
      Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced)
        GUID Alias: SCHEME_BALANCED
        Subgroup GUID: 238c9fa8-0aad-41ed-83f4-97be242c8f20  (Sleep)
          GUID Alias: SUB_SLEEP
          Power Setting GUID: 29f6c1db-86da-48c5-9fdb-f2b67b1f44da  (Sleep after)
            GUID Alias: STANDBYIDLE
            Minimum Possible Setting: 0x00000000
            Maximum Possible Setting: 0xffffffff
            Possible Settings increment: 0x00000001
            Possible Settings units: Seconds
          Current AC Power Setting Index: 0x00000000
          Current DC Power Setting Index: 0x00000384
      
      
      C:\>powercfg /query scheme_balanced sub_sleep hibernateidle
      Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced)
        GUID Alias: SCHEME_BALANCED
        Subgroup GUID: 238c9fa8-0aad-41ed-83f4-97be242c8f20  (Sleep)
          GUID Alias: SUB_SLEEP
          Power Setting GUID: 9d7815a6-7ee4-497e-8888-515a05f02364  (Hibernate after)
            GUID Alias: HIBERNATEIDLE
            Minimum Possible Setting: 0x00000000
            Maximum Possible Setting: 0xffffffff
            Possible Settings increment: 0x00000001
            Possible Settings units: Seconds
          Current AC Power Setting Index: 0x00000000
          Current DC Power Setting Index: 0x00000000
      
      
      
      		
      	

You must be logged in to reply to this topic.