Deployment of Power Plan Settings

Sometimes you have a need to deploy multiple pre-configured power plans to your users. This guide explains how to deploy power plans with a pre-defined GUID and plan name for easy reference. We will cover how to export a power plan, import a power plan, set a name for a power plan and finally, how to script the import process in PowerShell.

Exporting an Existing Power Plan

Power plan changes in Windows can be manipulated through the included powercfg utility. To export a power plan, we first have to retrieve a list of available plans. To do this; open an administrative command prompt and issue the command below:

powercfg /list
Listing available power plans

After you have a list of power plans, copy the GUID for the plan that you would like to export. Issue the export command:

powercfg /export {FILEPATH} {GUID}
Exporting a power plan

Importing a Power Plan

To import a power plan, we can use the same powercfg utility. Ideally, we’d have the exported power plan file stored on a network share or inside a deployment package if you are scripting the installation with SCCM.

Issue the following command to import a power plan:

powercfg /import {FILEPATH} {GUID}

It is important to use a GUID on the end of the import command, as we can then programatically set a new name for the power plan later on. We can keep the same GUID that the plan had when we exported it.

Importing a power plan

After importing the power plan, you can see that the same name is set from when we exported the plan. We may however want to set a new name. This can be done via the following command:

powercfg /changename {GUID} {NEW_NAME}
Changing the power plan name

Finally, we’ll want to set the plan as active. You can see in the image above that the asterisk is next to the ‘Balanced’ power plan. This is the current active power plan. To set a new active plan, issue the following command:

 powercfg /setactive {GUID}
Seeing the active power plan

As you can see above, our new ‘Contoso Eco Power Plan’ is now the active plan for this system.

Importing a Power Plan via a script.

To enable a mass deployment of the power plan across the enterprise, creating and deploying a script is necessary. Below is a snippet of code for the import process. Ideally this script and the exported power plan would either be hosted on a network share or inserted into a deployment package for SCCM to deploy.

<#
.SYNOPSIS
  This script imports the a Power Plan

.DESCRIPTION
  

.INPUTS
  None

.OUTPUTS Log File
  

.NOTES
  Version:        1.0
  Author:         Chris Scott
  Creation Date:  20/03/2023
  Purpose/Change: 

.EXAMPLE
  PS C:\> .\Deploy-PowerPlan.ps1
#>

#----------------------------[Declarations]-----------------------------

$scriptVersion = '1.0'
$planGUID = "eb40421b-7b88-4ed1-8aa1-2f71d8b6a801"
$planLocation = "\\fileshare\resources\powerplans\custom_powerplan.pow"
$planName = "Contoso Eco Power Plan"

#-----------------------------[Execution]-------------------------------


#Import the power plan with a set GUID
powercfg -import $planLocation $planGUID

#Set the name of the power plan
powercfg -changename $planGUID $planName

#Set the imported power plan as the active power plan.
powercfg -setactive $planGUID
This entry was posted in PowerShell and tagged , , , . Bookmark the permalink.

Leave a Reply