When a Windows computer enters sleep mode it ensures that WiFi adapters enters the device power state D3 (Sleep) and on resume ensure it puts it back to the device power state D0 (Full on).

Windows assumes that if a driver says it supports sleep states it handles this correctly, but this setting is known to cause some spontaneous disconnects with the access point (AP). Optionally Windows can be configured to place the WiFi adapters in device power state D4 (Off).

I wrote a PowerShell script that disables the “Allow the computer to turn off this device to save power” setting for all WiFi adapters.

Update 26/10/2017: Included an option to disable for all network adapters. 

Allow the computer to turn off this device to save power

According to KB2740020 this setting changes the behavior of when power needs to be saved (for instance when a computers enters the S3 sleep mode), it does not mean Windows will turn of this device when it wants to save power. If you read the setting you could assume that Windows does turns off a device when it tries to reduce power consumption, in fact that’s what some people do experience.  It gets worse:

Setting Explanation
Enabled / Checked When the machine goes into sleep mode the device power state is changed from D0 to D3 (sleep).
Disabled / Unchecked When the machine goes into sleep mode the device power state is changed from D0 to D4 (off).

So when the setting allow the computer to turn off this device to save power is enabled it actually puts it to sleep, not turn off. The result is an inverse of what it says :-/

Allow the computer to turn off this device to save power

Strangely enough later on the same article explains that by setting a certain registry value (PnPCapabilities) to 24 it will prevent Windows from turning off the network adapter (and use Wake-on-LAN). Either way, I created the script and applied it.



So I wrote a PowerShell script that queries all available WiFi adapters and disables the Allow the computer to turn off the device to save power.



The script runs without arguments but requires elevated privileges, this is enforced by the script.


Update 26/10/2017

If you want to disable powersave for all adapters, change line #71 from

If (($objNICproperties."*ifType" -eq 71) -and


If (($objNICproperties."*ifType" -eq 6 -or $objNICproperties."*ifType" -eq 71) -and

With special thanks to Ward Sprewers for the tip!



You can download the files here:  DisablePowerSavingForWLAN



14 Reacties

  1. Hi there,

    I like your handy script, just wondering if you have a similar script that will do the same for the Lan NIC. I have clients that after sleep mode, lose there mapped drives. I relatively new to powershell. Any help would be great.

  2. I need a script which will leave the LAN Adapter Network Cards (NIC or other words Ethernet) in the D3 state and able to do Wake On LAN from the Complete Shutdown State (S5). If you need to do a higher Dx state such as D0 that is fine with me. I am using a Windows 8.1 Pro computer. I used to be able to do Wake On LAN but at some point (I believe when I went to Windows 8.1 that capability stopped working). I believe now when Windows does shutdown, Windows puts the LAN Adapters into complete power off state as I cannot not see any lights on the Network Controller Port/Connector. Thanks.

  3. Why would anyone create this stupid setting? No one wants their network adapter to turn off whenever it feels like it. That’s just plain stupid. It never ceases to amaze me how a corporation of super geniuses like Intel and Microsoft can be such morons at the same time. They just need to quit screwing with people’s machines and leave well enough alone.

  4. Seems to be an error with the bit to disable for all adapters (on the file I downloaded it was line #78)
    Anyway, there are two html italic tags which prevent it from working – these need to be removed

  5. The statement from Verheij that when the Wi-Fi Adapter is in D3 state that it is in a sleep state I believe to be a false statement. First the D3 State is applicable to the LAN Adapter not the Wi-Fi State. My research in the past has indicated that the D3 state is considered to actually be the lowest power state of a LAN Adapter of which the purpose seems to be to allow the LAN Adapter to have enough power to respond to a special data packet or ‘Magic Packet’ allowing the LAN Adapter to turn on power to the motherboard to bring the computer out of an S5 Shutdown State. The S5 (Shutdown State) is not actually treated like a sleep state but rather is considered the complete Shutdown state of a computer and generally thought to be the powered off state except for the power necessary to keep the BIOS, Battery, Clock, etc. running or in other words much like a Standby State but it is not in Sleep.

    Windows 10 and possibly earlier has done something to apparently kill all power to the LAN Adapters (meaning I do not see the Data Lights and ‘Link’ light I believe it is called) and therefore I am assuming this means there is no power going to the LAN Adapter and without any power to the LAN Adapters the ‘Magic Packet’ cannot power up the computer. How Windows 10 accomplishes this I do not know but prior to this one could power on remotely a Windows computer by sending a ‘Magic Packet’ to the Windows computer’s LAN Adapter.

    I agree Microsoft should not be interfering with the way in which we control our computers in this manner. Microsoft should not be taking away functionality our computers have which we prefer to make use of. Microsoft is becoming too much like Apple in this regards.

  6. Hi, When i have try this to all network adapters ->
    If (($objNICproperties.”*ifType” -eq 6 -or $objNICproperties.”*ifType” -eq 71) -and
    It’s not working for me.
    Then i change and will remove and with script its working now.

    This i will be but in line 71
    If (($objNICproperties.”*ifType” -eq 6 -or $objNICproperties.”*ifType” -eq 71) -and

  7. Hi. I would appreciate if you could teach me what means “{0} \ {1}” and “”{0: D4}” -f” at the command line: “Set-ItemProperty -Path (“HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}” -f “{4D36E972-E325-11CE-BFC1-08002BE10318}”, ( “{0:D4}” -f $intNICid)) -Name “PnPCapabilities” -Value “24” -Type DWord” of the script you made. I would like to be able to undo the commands to the default Windows value if necessary, but could not understand or find the explanation on the Internet. Very grateful to understand a little more about Powershell. Sincerely, Edson

  8. Hey, I had to change the command line to launch it because we have a directory with a space in it. I don’t get any errors, but it also doesn’t change anything. Below is the command line. Please take a look. Thanks.

    c:\windows\system32\windowspowershell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -command “& {‘C:\installed software\DisablePowerSavingForWLAN.ps1’}”

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

Deze site gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.