Stop network adapter going to sleep on Windows 10

We were experiencing issues with the wireless network adapter going to sleep when not in use, and wanted to make sure it stays awake all the time.

There is a tickbox on the network adapter that needed to be unticked on the wireless card and also the network port on the laptop. The setting is Allow the computer to turn off this device to save power. Rather than doing this manually every time a laptop is rebuilt I found a powershell script and modified it to suit our needs.

screenshot

This is the original script that disables power saving on all Intel network cards.

$nics = Get-WmiObject Win32_NetworkAdapter | where {$_.Name.Contains('Intel')}

foreach ($nic in $nics)
{
    $powerMgmt = Get-WmiObject MSPower_DeviceEnable -Namespace root\wmi | where {$_.InstanceName.Contains($nic.PNPDeviceID)}
    $powerMgmt.Enable = $False
    $powerMgmt.psbase.Put()
}

 

I altered it to suit our needs and now the powershell script runs and outputs a log file.  It searches for all 4 of the network adapters we want to change, makes sure it can disable Power Management on that network adapter, then checks if power management is enabled and if it is then it disables it.

$file = "C:\NICpowerChange.log"
"Searching for AX88772A / Thinkpad / Lenovo / Intel" | Add-Content -Path $file

#find relevant network adapters
$nics = Get-WmiObject Win32_NetworkAdapter | where {$_.Name.Contains('AX88772A') -or $_.Name.Contains('Thinkpad') -or $_.Name.Contains('Lenovo') -or $_.Name.Contains('Intel')}

$nicsFound = $nics.Count
"number of network adapters found: ", $nicsFound | Add-Content -Path $file

foreach ($nic in $nics)
{
   $powerMgmt = Get-WmiObject MSPower_DeviceEnable -Namespace root\wmi | where {$_.InstanceName -match [regex]::Escape($nic.PNPDeviceID)}
 
   # check to see if power management can be turned off
   if(Get-Member -inputobject $powerMgmt -name "Enable" -Membertype Properties){

     # check if powermanagement is enabled
     if ($powerMgmt.Enable -eq $True){
       $nic.Name, "----- Enabled method exists. PowerSaving is set to enabled, disabling..." | Add-Content -Path $file
       $powerMgmt.Enable = $False
       $powerMgmt.psbase.Put()
     }
     else
     {
       $nic.Name, "----- Enabled method exists. PowerSaving is already set to disabled. skipping..." | Add-Content -Path $file
     }
   }
   else
   {
     $nic.Name, "----- Enabled method doesnt exist, so PowerSaving cannot be set" | Add-Content -Path $file 
   }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s