top of page
Search

(116) Microsoft Intune - Custom Power Option as a Win32 App

  • Writer: Mr B SOE way
    Mr B SOE way
  • Mar 30, 2024
  • 1 min read

Updated: Apr 6, 2024

As part of a customer's request to deploy a Win32 app as Power options. To get a list of "Power Plans" within the device, go to Command Prompt, then type in: powercfg /l which loads the following:






Create and save the following as Install.ps1:

POWERCFG -DUPLICATESCHEME 381b4222-f694-41f0-9685-ff5bb260df2e 381b4222-f694-41f0-9685-ff5bb260abcd
POWERCFG -CHANGENAME 381b4222-f694-41f0-9685-ff5bb260abcd "XXXXX 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

Create and save the following as Uninstall.ps1:

POWERCFG -SETACTIVE 381b4222-f694-41f0-9685-ff5bb260df2e
POWERCFG -DELETE 381b4222-f694-41f0-9685-ff5bb260abcd

Create and save the following as Detection.ps1

$Path = "HKLM:\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\381b4222-f694-41f0-9685-ff5bb260abcd"
$Name = "FriendlyName"
$Type = "EXPANDSTRING"
$Value = "XXXXX 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
}

Package this up as a Win32 App with the following:


Under Program:

Install Command: powershell -exe bypass -file Install.ps1

Uninstall Command: powershell -exe bypass -file Uninstall.ps1

Device restart behaviour: No specific action


Under Detection Rules:

Rule type: Use Detection.ps1


It will then set the Power Option plan like this.


 
 
 

Opmerkingen


bottom of page