Solved Disable Power Management for all devices via script


shoober420

Active member
Member
Local time
12:07 AM
Posts
82
Visit site
OS
Windows 11 27729
Im trying to disable all Power Management options for all devices found under Device Manager. This includes all USB devices and NICs. I came across the "Disable-NetAdapterPowerManagement" command and ran:
Code:
Disable-NetAdapterPowerManagement -Name *

The "Allow the computer to turn off this device to save power" and "Allow this device to wake the computer" were still checkmarked and enabled for my NIC card, even after restart.

Is there another PowerShell command or commands I can run to disable all Power Management options for all my devices?
 
Windows Build/Version
Windows 27729

My Computer

System One

  • OS
    Windows 11 27729
    Computer type
    PC/Desktop
    CPU
    i9 13900kf @5.7ghz all P-Cores
    Motherboard
    Aorus Master Z790
    Memory
    32gb DDR5 7200
    Graphics Card(s)
    RTX 4090
    Other Info
    https://www.github.com/shoober420
I have a post for disabling the "wake the computer" option over here: Disable waking up from hibernation for good

If you change the class name in the query to MSPower_DeviceEnable, it should turn off the "turn off this device" option, but I don't have a PC I'm willing to try it on. :)
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
When i run that command string from the linked thread post, i get this error:

Code:
Set-CimInstance : Invalid object
At line:1 char:1
+ Set-CimInstance -Query 'SELECT InstanceName FROM MSPower_DeviceWakeEn ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-CimInstance], CimException
    + FullyQualifiedErrorId : HRESULT 0x8004100f,Microsoft.Management.Infrastructure.CimCmdlets.SetCimInstanceCommand
 
Last edited:

My Computer

System One

  • OS
    Windows 11 27729
    Computer type
    PC/Desktop
    CPU
    i9 13900kf @5.7ghz all P-Cores
    Motherboard
    Aorus Master Z790
    Memory
    32gb DDR5 7200
    Graphics Card(s)
    RTX 4090
    Other Info
    https://www.github.com/shoober420
Works fine here, along with changing the class name for the power management setting. Perhaps one of your other performance tweaks rendered this not an option.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
I've been looking for something like this, too. Unticking all those Power Management tab boxes in Device Manager is pretty tedious.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2
    Computer type
    Laptop
    Manufacturer/Model
    Microsoft Surface Pro
    Memory
    16GB
  • Operating System
    Windows 11 Pro 23H2
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkPad
    Memory
    32GB
Works fine here, along with changing the class name for the power management setting. Perhaps one of your other performance tweaks rendered this not an option.
Im on a fresh WinRE restart (keep my files), so the machine hasnt had any tweak scripts applied to it. I will try and look into why its not working further.

@cheaterslick
I made a script that will disable all the power management options for all devices based on pseymours command string. Could you test it out? Make sure your "Set-ExecutionPolicy" allows scripts from the internet to be launched.

 
Last edited:

My Computer

System One

  • OS
    Windows 11 27729
    Computer type
    PC/Desktop
    CPU
    i9 13900kf @5.7ghz all P-Cores
    Motherboard
    Aorus Master Z790
    Memory
    32gb DDR5 7200
    Graphics Card(s)
    RTX 4090
    Other Info
    https://www.github.com/shoober420
@shoober420 PowerShell has a pause command also; you can avoid calling out to cmd if you want.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
l
PowerShell has a pause command also; you can avoid calling out to cmd if you want.
I was looking for it a couple of days ago, and couldnt find anything. The closest thing I found was a "sleep" command, which I dont want.

Code:
Start-Sleep -Seconds 5

Another option I saw when googling was:

Code:
Read-Host -Prompt "Press any key to continue..."

Although it may work, it doesnt actually say "pause" anywhere which bothers me. It also uses more characters for the same effect as whats in the script now.

Heres another one i found googling.

Code:
Wait-Event -sourceIdentifier "ProcessStarted" -timeout 90

This also uses a lot of characters for the same effect as whats in the script. They both also look very ugly.


This is why i opted for whats currently in the script, which is:

Code:
cmd /c 'pause'

I also think this looks a lot nicer than the "Read-Host" method and "Wait-Event" method. It also is more readable, meaning if someone looks at it they can give a guess what it does over "Read-Host -Prompt" and "Wait-Event -sourceIdentifier". IMO, the other methods simply look ugly.
 
Last edited:

My Computer

System One

  • OS
    Windows 11 27729
    Computer type
    PC/Desktop
    CPU
    i9 13900kf @5.7ghz all P-Cores
    Motherboard
    Aorus Master Z790
    Memory
    32gb DDR5 7200
    Graphics Card(s)
    RTX 4090
    Other Info
    https://www.github.com/shoober420
I thought I found a work around but was out of luck. I came across the powercfg method in the thread you posted in. Although the powercfg method would work, I have to specify a specific device to disable power management options for. Im trying to simply disable for all devices across multiple different computers. Making a script with specific hardware names is not what im looking for. Using "*" unfortunately doesnt work.

Code:
powercfg -devicedisablewake "*"
 

My Computer

System One

  • OS
    Windows 11 27729
    Computer type
    PC/Desktop
    CPU
    i9 13900kf @5.7ghz all P-Cores
    Motherboard
    Aorus Master Z790
    Memory
    32gb DDR5 7200
    Graphics Card(s)
    RTX 4090
    Other Info
    https://www.github.com/shoober420
By golly, I think I did it, at least for the network adapter thus far. Registry method, the true method. We are looking for the PnPCapabilities registry key that effects all power management options.


Fortunately, its under the same registry key string as the other NIC options under NIC properties.

Code:
for /f %%n in ('Reg query "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}" /v "*SpeedDuplex" /s ^| findstr  "HKEY"') do (

reg add "%%n" /v "PnPCapabilities" /t REG_DWORD /d "0x00000118" /f

or you can use the old way i used to do.

Code:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\000X" /v "PnPCapabilities" /t REG_DWORD /d "0x00000118"

for 000X, would be 0, 1, 2, 3, 4 etc depending on how many devices are present

this bypasses the need for using powershell to modify registry. we talk directly to registry and avoid the need for powershell to do this for us

ill post back later with how to do this for usb devices
 

My Computer

System One

  • OS
    Windows 11 27729
    Computer type
    PC/Desktop
    CPU
    i9 13900kf @5.7ghz all P-Cores
    Motherboard
    Aorus Master Z790
    Memory
    32gb DDR5 7200
    Graphics Card(s)
    RTX 4090
    Other Info
    https://www.github.com/shoober420
@cheaterslick
I made a script that will disable all the power management options for all devices based on pseymours command string. Could you test it out? Make sure your "Set-ExecutionPolicy" allows scripts from the internet to be launched.


Thanks but I did the dirty time-consuming deed, already. I can see why MS has them enabled by default for enterprise use, but for home users to have to go through all that crap... 😡 Not good.

The powercfg -devicequery wake_armed command was a big help in tracking down the ones that I missed.

However, once you and @pseymour work it out, I will be able to save your script for future use because I know I will run into this again.

I want to thank both of you for your efforts.
 
Last edited:

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2
    Computer type
    Laptop
    Manufacturer/Model
    Microsoft Surface Pro
    Memory
    16GB
  • Operating System
    Windows 11 Pro 23H2
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkPad
    Memory
    32GB
looks like its complete. im just hoping the "class guid" is consistant for mice and keyboards on windows. it would appear to be, as ive come across many threads about NICs and the "class guid" being the same as mine.

Code:
rem # Disable Power Management option on all devices

rem # NIC
for /f %%n in ('Reg query "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}" /v "*SpeedDuplex" /s ^| findstr  "HKEY"') do (

reg add "%%n" /v "PnPCapabilities" /t REG_DWORD /d "0x00000118" /f
)

rem # Keyboard
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e96b-e325-11ce-bfc1-08002be10318}\0000" /v "PnPCapabilities" /t REG_DWORD /d "0x00000118" /f

rem # Mouse
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e96f-e325-11ce-bfc1-08002be10318}\0000" /v "PnPCapabilities" /t REG_DWORD /d "0x00000118" /f

PAUSE

 

My Computer

System One

  • OS
    Windows 11 27729
    Computer type
    PC/Desktop
    CPU
    i9 13900kf @5.7ghz all P-Cores
    Motherboard
    Aorus Master Z790
    Memory
    32gb DDR5 7200
    Graphics Card(s)
    RTX 4090
    Other Info
    https://www.github.com/shoober420
Neato, but you said all devices, not NICs and input devices. The customer changed the specs mid-stream! ;-)
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
i spoke too soon, it doesnt work. i of course want them disabled for all devices, its just input and NICs are most common. im going to still try and figure out how to do this. windows shouldnt make it this hard. no one wants to go through every devices properties and manually untick everything. thats windows for you
 

My Computer

System One

  • OS
    Windows 11 27729
    Computer type
    PC/Desktop
    CPU
    i9 13900kf @5.7ghz all P-Cores
    Motherboard
    Aorus Master Z790
    Memory
    32gb DDR5 7200
    Graphics Card(s)
    RTX 4090
    Other Info
    https://www.github.com/shoober420
no one wants to go through every devices properties and manually untick everything. thats windows for you
Almost no one wants these settings disabled for all devices. For those that do, that’s why MSFT added the WMI functions, accessible via PowerShell and other methods.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
Almost no one wants these settings disabled for all devices. For those that do, that’s why MSFT added the WMI functions, accessible via PowerShell and other methods.
me saying "no one" doesnt mean im speaking for everyone, it means im speaking for the people who tweak their system, like gamers or powerusers in a corporate environment. what other methods?
 

My Computer

System One

  • OS
    Windows 11 27729
    Computer type
    PC/Desktop
    CPU
    i9 13900kf @5.7ghz all P-Cores
    Motherboard
    Aorus Master Z790
    Memory
    32gb DDR5 7200
    Graphics Card(s)
    RTX 4090
    Other Info
    https://www.github.com/shoober420
Anything that can run WMI functions. VBScript, .NET code, WMIC? Not sure about WMIC; never checked and it's deprecated now anyway. But these days, if you're doing something new, PowerShell is the way to go, and that's what my suggestion was above.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
because this isnt the first time ive ran into trouble with powershell. i even googled how to disable the power management options for the usb controllers and another powershell command string failed.


other powershell commands seem to work for me. my NICProperties.ps1 powershell scripts works. i ran "winget install microsoft.powershell" to make sure i have the latest powershell and i do. maybe its a bug with the windows insider build im on (27729).
 

My Computer

System One

  • OS
    Windows 11 27729
    Computer type
    PC/Desktop
    CPU
    i9 13900kf @5.7ghz all P-Cores
    Motherboard
    Aorus Master Z790
    Memory
    32gb DDR5 7200
    Graphics Card(s)
    RTX 4090
    Other Info
    https://www.github.com/shoober420

Latest Support Threads

Back
Top Bottom