POWERCFG to get AC index value

Sara 401 Reputation points
2021-03-16T04:04:40.367+00:00

I am trying to query the "current AC power setting index" , so if the value is not 0 it has to change the value to 0 , I am able to query the entire display setting using below script , but struck on getting the current AC power setting index value . Any help is much appreciated.

if (powercfg /q|Select-String -Pattern "(display)" -Context 9 ) -split "rn" | select -last 9

![78075-image.png][1] [1]: /api/attachments/78075-image.png?platform=QnA

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,362 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,571 Reputation points Microsoft Vendor
    2021-03-16T06:10:13.097+00:00

    Hi @Saravanaraj-6475 ,

    The power setting in the screenshot is "Turn off display after". To get the current AC power setting index value you can try something like below

    (powercfg /q|Select-String -Pattern "\(display\)" -Context 0,9) -match '(?<=Current DC Power Setting Index: )\w+$'  
    $Matches.Values  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful