How to install custom power plan using Microsoft Intune

Overview

This knowledge base will demonstrate how to create your own custom power plan which can be deployed as a Win32 application. Once this is deployed to the end user device, users can customised to their needs.

Steps

By opening in command prompt, then typing in powercfg /l, this will provide you a list of power scheme on your device. The Power Scheme with a * is the active power plan.

  1. Prepare the Install.ps1 script with the following:
    POWERCFG -DUPLICATESCHEME 381b4222-f694-41f0-9685-ff5bb260df2e 381b4222-f694-41f0-9685-ff5bb260abcd
    POWERCFG -CHANGENAME 381b4222-f694-41f0-9685-ff5bb260abcd "Devicie Power Plan"
    POWERCFG -SETACTIVE 381b4222-f694-41f0-9685-ff5bb260abcd
    POWERCFG -Change -monitor-timeout-ac 0
    POWERCFG -CHANGE -monitor-timeout-dc 0
    POWERCFG -CHANGE -disk-timeout-ac 0
    POWERCFG -CHANGE -disk-timeout-dc 0
    POWERCFG -CHANGE -standby-timeout-ac 0
    POWERCFG -CHANGE -standby-timeout-dc 0
    POWERCFG -CHANGE -hibernate-timeout-ac 0
    POWERCFG -CHANGE -hibernate-timeout-dc 0
    1st line: It will duplicate the following "Balanced" power scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e. It will create a custom power scheme GUID: 381b4222-f694-41f0-9685-ff5bb260abcd where the last four characters can be modified.

    2nd line: It will set the name of custom power scheme GUID: 381b4222-f694-41f0-9685-ff5bb260abcd to "Devicie Power Plan"

    3rd line: It will set "Devicie Power Plan" scheme as active.

    4th line: It will set the timeout when the monitor while plugged in to 0 minutes.

    5th line: It will set the timeout when monitor is on battery to 0 minutes.

    6th line: It will set the hard disk timeout to 0 minutes while plugged in.

    7th line: It will set the hard disk timeout to 0 minutes while on battery.

    8th line: It will change the sleep timeout to 0 minutes while plugged in.

    9th line: It will change the sleep timeout to 0 minutes while on battery.

    10th line: It will change the hibernate timeout to 0 minutes while plugged in.

    11th line: It will change the hibernate timeout to 0 minutes while on battery.

  2. Prepare the Uninstall.ps1 script with the following: 
    POWERCFG -SETACTIVE 381b4222-f694-41f0-9685-ff5bb260df2e
    POWERCFG -DELETE 381b4222-f694-41f0-9685-ff5bb260abcd
    1st line: It will set the balanced power scheme to active.
    2nd line: It will delete the custom power plan scheme.

  3. Prepare the Detection.ps1 script with the following: 
    $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\381b4222-f694-41f0-9685-ff5bb260abcd"
    $Name = "FriendlyName"
    $Type = "EXPANDSTRING"
    $Value = "Devicie Power Plan"

    Try {
    $Registry = Get-ItemProperty -Path $Path -Name $Name -ErrorAction Stop | Select-Object -ExpandProperty $Name
    If ($Registry -eq $Value){
    Write-Output "Detected"
    Exit 0
    }
    Exit 1
    }
    Catch {
    Exit 1
    }
  4. The final output should look like this.
  5. Then using Microsoft Intune Win32 App Packaging tool, wrap into a .intunewin format.

  6. Navigate to Microsoft Intune portal, then select Apps then select By platform: Windows then select Add. Select App type: Windows app (Win32).
  7. Under App Information, select app package file.

    Fill in the details like under App information:
    Name:
    Description:
    Publisher:

    Select Next.

  8. Under Program, enter in the following:
    Install command:
    %windir%\sysnative\windowspowershell\v1.0\powershell.exe -executionPolicy bypass -windowstyle hidden -file "./Install.ps1"
    Uninstall command:
     %windir%\sysnative\windowspowershell\v1.0\powershell.exe -executionPolicy bypass -windowstyle hidden -file "./Uninstall.ps1
    Installation time required (mins): 60 
    Allow available uninstall: Yes
    Install behaviour: System
    Device restart behaviour: No specific behaviour
    Select Next.
  9. Under Requirements, select the following:
    Operating system architecture: 64-bit
    Minimum operating system: Windows 10 1903
  10. Under Detection Rules, select the following:
    Rules format: Use a custom detection script
    Script file: select Detection.ps1 from Step 3.
    Run script as 32-bit process on 64-bit clients: No
    Enforce script signature check and run script silently: No
  11. Under Dependencies, leave as default and select Next.
  12. Under Supersedence, leave as default and select Next.
  13. Under Assignments, select the assignments and select Next.
  14. Under Review + create, review all settings and select Create.
  15. On the device, go to Company Portal and run Sync. Then go to Power Plan via search to see the custom deployed Power Plan.