question

Saravanaraj-6475 avatar image
0 Votes"
Saravanaraj-6475 asked ·

POWERCFG to get AC index value

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 "`r`n" | select -last 9




![78075-image.png][1] [1]: /answers/storage/attachments/78075-image.png

windows-server-powershell
image.png (78.9 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered ·

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.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.