Disabling Idle Power Save using Intune and PowerShell

One of our customers sought a solution to disable Idle Power Save on their Realtek USB GbE network adapters using Intune. Because of that setting, their users were disconnected from their Remote Desktop sessions multiple times during the day. This blog post will show you how to disable that setting using Intune, a Windows app (Win32), or a Remediation script.

What is Idle Power Save?

Some network adapters support this feature, which lowers power usage, which is great, but when combined with certain network cards and/or docking stations, it causes problems and disconnects.

How do the scripts work?

The solution consists of a Detection script and a Remediation script. The Detection script checks if a network adapter on the system supports the Idle Power Save setting and if that setting is Enabled. If so, it will exit with an error code and start the Remediation script. If not (If the setting is already configured to Disabled or there is no adapter present with that option), it will exit and won’t do anything.

The Remediation script loops through all the adapters that support the Idle Power Save setting and changes the Enabled setting to Disabled.

How to add it to Intune

Windows app (Win32)

If you don’t have the correct licensing for Remediation scripts, then you can use the Windows app (Win32) option. This will check the settings on the computer a few times per day, which will be enough to fix the issue. If the driver is updated, the settings might be set to Enabled again, and then Intune will detect that and fix it again. Because it’s a Windows App (Win32), you can assign an uninstall group to revert the changes to the adapters and change the setting back to Enabled if needed.

Creating the .IntuneWin package

Follow these steps to create the package: (First, install the IntuneWinAppUtil tool and save that somewhere in your Path)

  • Create a new folder on your system, c:\temp\DisableIdlePowerSave, for example.
  • Copy the Install.ps1 and Uninstall.ps1 files to that folder. (You can find them on my GitHub page and on the bottom of this blog post)
  • Start a command-prompt
  • Run IntuneWinAppUtil -c C:\Temp\DisableIdlePowerSave -s C:\Temp\DisableIdlePowerSave\Install.ps1 -o C:\Temp\DisableIdlePowerSave -q to create the .intunewin package in the folder.

Adding the .IntuneWin package to Intune

Follow these steps to upload the package and assign it in Intune:

  • Go to Windows – Microsoft Intune admin center (Windows Apps)
  • Select Add
  • Select Windows app (Win32) and click Select
  • Click Select app package file
  • Select the folder icon, browse, and select the created .IntuneWin file from the step above, and click OK
  • Fill in the details (Name, Description, Publisher, App Version) and select Next
  • Use powershell.exe -executionpolicy bypass -file .\install.ps1 as the Install command, and powershell.exe -executionpolicy bypass -file .\uninstall.ps1 as the Uninstall command.
  • Make sure that the Install behavior is set to System
  • Select Next
  • Select Operating system architecture and select 32-bit and 64-bit
  • Select Minimum operating system and select your organization’s minimum build
  • Select Next
  • Select Rules format and select Use a custom detection script
  • Select the folder icon, browse, and select the Detection.ps1 file (You can find it on my GitHub page and on the bottom of this blog post)
  • Select Next, Next, Next and Next
  • Select Add group, select the desired group that you want to deploy this package to, and click Select
  • Select Next and Create to complete adding the package to Intune

Remediation

If you have the correct licensing, you can use the Remediation option in Intune to run the Detection and Remediation script once, daily, or hourly. If the adapter driver is updated and the setting is back to Enabled again, the Remediation process will change it back to Disabled again within the schedule you configured.

Adding the Remediation scripts to Intune

You can add the scripts (You can find them on my GitHub page and at the bottom of this blog post) to Intune by following these steps:

  • Go to Devices – Microsoft Intune admin center
  • Select Create
  • Fill in the details (Name, Description, Publisher) and select Next
  • Select the folder icon next to the Detection script file line, browse, and select the Detection.ps1 file.
  • Select the folder icon next to the Remediation script file line, browse, and select Install.ps1 file.
  • Make sure that Run this script using the logged-on credentials button is set to No and Select Next
  • Select Next
  • Click Select groups to include, select the desired group, and click Select.
  • Select Daily in the Schedule column and configure the Frequency to Once, Hourly, or Daily and select Apply
  • Select Next and Create to complete adding the Remediation scripts to Intune.

Important note

The script checks if there are network adapters with Idle Power Save enabled and disables it if found. Disabling it will cause a short network disconnect and connection; users should know that. In this case, this will only occur once instead of multiple times a day, and I don’t think the affected users will mind that 😉

The scripts

These are the scripts that I used :

Detection.ps1

try {
    $adapters = Get-NetAdapterAdvancedProperty -DisplayName 'Idle Power Saving' -ErrorAction SilentlyContinue | Where-Object RegistryValue -eq '1'
    if ($null -eq $adapters) {
        Write-Output 'No adapter(s) found with Idle Power Saving enabled, nothing to do...'
        exit 0
    }
    else {
        Write-Output 'Adapter(s) found with Idle Power Saving enabled, disabling now... '
        exit 1
    }
} 
catch {
    Write-Output 'No adapter(s) found with Idle Power Saving enabled, nothing to do...'
    exit 0
}

Install.ps1

$adapters = Get-NetAdapterAdvancedProperty -DisplayName 'Idle Power Saving' | Where-Object RegistryValue -eq '1'
foreach ($adapter in $adapters) {
    Set-NetAdapterAdvancedProperty -InterfaceDescription $adapter.InterfaceDescription -DisplayName 'Idle Power Saving' -RegistryValue '0'
}

Uninstall.ps1

$adapters = Get-NetAdapterAdvancedProperty -DisplayName 'Idle Power Saving' | Where-Object RegistryValue -eq '0'
foreach ($adapter in $adapters) {
    Set-NetAdapterAdvancedProperty -InterfaceDescription $adapter.InterfaceDescription -DisplayName 'Idle Power Saving' -RegistryValue '1'
}

Download the script(s) from GitHub here.

6 thoughts on “Disabling Idle Power Save using Intune and PowerShell

  1. Thank you for your Post and Script – I hope it solves some user interruptions in our tenant.

    I had a little Issue with the Script, because our Computers are set up in German. The “Displayname” is “aktiviert” instead of “enabled”.
    I am definitely no PowerShell Expert, but i think if you change $adapters = to the following:
    $adapters = Get-NetAdapterAdvancedProperty -DisplayName ‘Idle Power Saving’ | Where-Object RegistryValue -eq ‘1’
    And the Set-NetadapterAdvancedProperty to the following:
    Set-NetAdapterAdvancedProperty -InterfaceDescription $adapter.InterfaceDescription -DisplayName ‘Idle Power Saving’ -RegistryValue ‘0’

    Then the Script should work hopefully in every install-language. At least in German Environments, it seems to work.

    Kind regards
    Dave

    • I always seem to forget that not all computers are configured to be in English 🙁 Thanks, just tested it and works 🙂 I will update the scripts and the blog with that!

      • Sadly there are computers configured to other languages… But I feel good, that I could improve a Script which is featured in the Intune Newsletter from Andrew Taylor.

  2. I have the same here in the Netherlands, computers configured to be Dutch… Sometimes I can’t understand what the error on the screen is 😉 And your name is in my GitHub update too, thanks againg and have a great weekend!

  3. Harm,

    Regarding your “Important note”. You could add the parameter -NoRestart to prevent the network adapter from restarting directly.

    Downside is that the settings will take affect on the next reboot. But it won’t interfere the user 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.