Windows 10 Power Options and Intune – Discover with Joy

0
Windows 10 Power Options and Intune

Windows 10 Power Options and Intune – we do see a few queries in the community space on this topic.

How to manage Windows 10 Power Options using Intune?

As such though of writing this short post to present my ideas on the same.

Manage Windows 10 Power Options using Intune – Settings configurable from the portal (UI)

Intune, by default, allows you to create Device Restrictions profile type for Windows 10 to control the Power Options.

Window 10 Power Options - Device restrictions profile will let you configure the settings for Lid close action, Power button, Sleep button actions, Enabling Energy Saver and Hybrid sleep from the UI.
Windows 10 Power Options – Device restrictions profile will let you configure the settings for Lid close action, Power button, Sleep button actions, Enabling Energy Saver and Hybrid sleep from the UI.Windows 10 Power Options – Device restrictions profile will let you configure the settings for Lid close action, Power button, Sleep button actions, Enabling Energy Saver and Hybrid sleep from the UI.

For both Battery and Plugged In, you get to configure from here, the actions for

  • Enable Energy Saver
    • Power/EnergySaverBatteryThresholdOnBattery
    • Power/EnergySaverBatteryThresholdPluggedIn
  • Lid close
    • Power/SelectLidCloseActionOnBattery
    • Power/SelectLidCloseActionPluggedIn
  • Power button
    • Power/SelectPowerButtonActionOnBattery
    • Power/SelectPowerButtonActionPluggedIn
  • Sleep button
    • Power/SelectSleepButtonActionOnBattery
    • Power/SelectSleepButtonActionPluggedIn
  • Hybrid Sleep
    • Power/TurnOffHybridSleepOnBattery
    • Power/TurnOffHybridSleepPluggedIn

All these features were added to Policy CSP with Windows 10 1903

Manage Windows 10 Power Options using Intune – Settings configurable via OMA-URI

At the time of writing this article, Policy CSP has 22 settings in total related to Power Options, of which 8 settings are configurable from the UI as shown above.

Thus, if you need to control/configure the other 12 Power Option features which are not natively available in UI, you would require to create a Custom OMA-URI profile for the same.

You can easily create the OMA-URI path referring to the registry. OMA-URI Path Construction ./Device/Vendor/MSFT/Policy/Config/Power/<PolicySettingsName>

Windows 10 Power Option and Intune - Create OMA-URI path for custom CSP profile to manage Power Options
Windows 10 Power Option and Intune – Create OMA-URI path for custom CSP profile to manage Power Options

As Microsoft states, these are ADMX backed policy and as such requires special SyncML format to Enable or Disable.

What if your Windows 10 workstations are still running 1803 or 1809? Good old PowerShell way…

It is quite possible that due to Microsoft extending the support for 1803 and 1809 versions of Windows 10 Enterprise and Education SKU till 11th of May 2021(ref) as of today, a majority of your production environment workstations are still on either of these two versions and you have not yet made the move to 1903/1909.

However, if you check the documentation of Policy CSP for Power Option configurations, many nodes were added since Windows 10 version 1903. As such, there is no gurantee that those were backported to the previous Windows 10 versions as well.

In such cases, the only other way that I could think of is to make use of a PowerShell script deployment from Intune to configure the power-related settings instead.

For example, if you would want to manage the Lid close action on an Intune managed Windows 10 1803/1809 device, you may resort to using a PS script deployment. You would require only two lines of code to set the value you require for the Lid close action in the format as below

Format
======
 
powercfg -SETACVALUEINDEX <Power Scheme GUID> <Subgroup GUID> <Power Setting GUID> <Index Value>
powercfg -SETDCVALUEINDEX <Power Scheme GUID> <Subgroup GUID> <Power Setting GUID> <Index Value>
 
Where Index Value is as
 
Index Value    Action
0                   Do Nothing
1                   Sleep
2                   Hibernate
3                   Shutdown

For those who are new to using the command line, you can probably start by retrieving the current active power scheme of the system using the command

powercfg -getactivescheme

Windows 10 Power Options - Using commadline cmdline powercfg to retrieve the active power scheme
Windows 10 Power Options – Using commadline cmdline powercfg to retrieve the active power scheme

Note the GUID and use it to query more details about it using the command

powercfg -q <GUID of Power Scheme>

Note! the GUID and use it to query more details about it. The command powercfg -q <GUID of Power Scheme>

This results a lot of output on the screen showing the various details of the current power scheme. The below snap shows the setting that we are talking here about

Windows 10 Power Options - Using commadline cmdlet powercfg to query a power scheme to retrieve the particular subgroup GUID and the required Power setting GUID
Windows 10 Power Options – Using commadline cmdlet powercfg to query a power scheme to retrieve the particular subgroup GUID and the required Power setting GUID

Note the Subgroup GUID and the Power Setting GUID with which we will prepare the command to set the appropriate index value for the settings.

So for my system which is in Balanced power scheme, to set the “Lid close action” to “Do nothing“, I would require to run the following commands

powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0
 
powercfg -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0

As such, for a particular feature, if you find there is no

  • policy settings available to be configured from the UI
  • CSP node available to create a custom OMA-URI profile
  • ADMX tempate settings available in Intune

you can always rely on your good old frined – PowerShell šŸ™‚

You can also create a custom ADMX file pertaining to the settings you would want to control and manage, ingest the ADMX using Intune, and then use the custom OMA-URI to set the policy settings of the ingested ADMX policy. But it is a complex and time-consuming process.

Manage Windows 10 Power Options using PowerShell script from Intune – Example Scenario

Let’s take an example of a requirement on which I worked in one of my assignments.

Requirement:

Manage Power and Sleep settings for both Battery and Plugged In.

  • Set “Turn off the display” to Never and Never
  • Set “Put the computer to sleep” to Never and Never
Windows 10 Power Options - Requirement to set the settings "Turn off the display" and "Put the computer to sleep" to Never and Never for both AC/DC power scenario
Windows 10 Power Options – Requirement to set the settings “Turn off the display” and “Put the computer to sleep” to Never and Never for both AC/DC power scenario
  • Uncheck ā€œTurn on Fast Startupā€ from Startup options
Windows 10 Power Options - Requirement to uncheck "Turn on fast startup"
Windows 10 Power Options – Requirement to uncheck “Turn on fast startup”

Assessment:

The first two settings are possible via custom OMA-URI profile utilizing the Policy CSP. However, for the 3rd requirement I could not figure out any node of PolicyCSP /Power that seems to help me achieve the goal. As such the decision to fallback to PowerShell.

Building the Script:

Uncheck ā€œTurn on Fast Startupā€ requires a registry edit to set the DWORD value of reg_key HiberbootEnabled to 0. The reg_key is under reg_path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Power

The commands to set the values for “Put the computer to sleep” and “Turn off the display” to Never for all scenarios is as

powercfg -change -monitor-timeout-ac 0
powercfg -change -monitor-timeout-dc 0
powercfg -change -standby-timeout-ac 0
powercfg -change -standby-timeout-dc 0

I am no scripting expert and as such these script examples are for illustration purposes only and you may find this elementary!

The Actual Script:

powercfg -change -monitor-timeout-ac 0
powercfg -change -monitor-timeout-dc 0
powercfg -change -standby-timeout-ac 0
powercfg -change -standby-timeout-dc 0
 
$Path = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power"
$Name = "HiberbootEnabled"
$value = "0"
 
#Check if $Path exist. If not, create $Path and then add the item and set value.
 
If (!(Test-Path $registryPath))
 
{
    New-Item -Path $registryPath -Force | Out-Null
    New-ItemProperty -Path $registryPath -Name $Name -Value $value -PropertyType DWORD -Force | Out-Null
}
 
 ELSE
{
    New-ItemProperty -Path $registryPath -Name $Name -Value $value -PropertyType DWORD -Force | Out-Null
}

The End

This post was just to present my ideas and approach when it comes to managing Windows 10 Power Options from Intune. However, I would be very keen to hear back from you, your ideas, and the approach that you have taken while working on this particular topic for any projects or within your own environment.

Well, that was it for today.

If you are reading my article for the first time, here is a link to my profile from where you can access all my other articles. Give them a read as well!

Last but not the least, continue to stay safe…

LEAVE A REPLY

Please enter your comment!
Please enter your name here

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