Script to disable "turn off this device to save power" for NIC Power Management (PowerShell)

Introduction

This PowerShell Script illustrates how to disable "turn off this device to save power" feature in Power Management.

Scenarios

Many users want to disable the option in network device called: The computer turn off this device to save power. Now, this script can help users to disable "turn off this device to save power" feature in Power Management of all physical network adapters.

Script

Step 1: Click Start, type powershell in the search box on the Start Menu, right-click the Windows PowerShell icon, and then click Run Windows PowerShell as administrator. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.

Step 2: Run the script in the Windows PowerShell Console, type the command: <Script Path> at the prompt.

For example, type D:\Script\DisableNetworkAdapterPnPCapabilities.ps1

This is shown in the following figure.

Step 3: Finally, when the script finishes running, it will return a brief message in the current Windows PowerShell Console. And you will see this option has been disabled as expected.

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.

PowerShell
Edit|Remove
If($PnPCapabilitiesValue -eq 0{ 
    #check whether change value was successed. 
    Try 
    {     
        #setting the value of properties of PnPCapabilites to 24, it will disable save power option. 
        Set-ItemProperty -Path $KeyPath -Name "PnPCapabilities" -Value 24 | Out-Null 
        Write-Host """$PhysicalAdapterName"" - The option ""Allow the computer to turn off this device to save power"" was disabled." 
         
        Write-Warning "It will take effect after reboot, do you want to reboot right now?" 
        [string]$Reboot = Read-Host -Prompt "[Y] Yes  [N] No   (default is 'N')" 
        If ($Reboot -eq "y" -or $Reboot -eq "yes")  
        { 
            Restart-Computer -Force 
        }} 
    Catch 
    { 
        Write-Host "Setting the value of properties of PnpCapabilities failed." -ForegroundColor Red 
    }}

 

Prerequisite

Windows PowerShell 2.0 

Related forum threads:

http://social.technet.microsoft.com/Forums/en-US/windowsserver2008r2networking/thread/eb42064a-8ee2-4a63-867b-4ab416684c8e 
http://social.technet.microsoft.com/Forums/en-US/w7itpronetworking/thread/89a2797e-0c6e-4e53-b9dd-cb7f2fca5c65 
http://us.generation-nt.com/pnpcapabilities-powermanagement-windows-7-help-199014021.html