Skip to main content

Power Plan - Set/Create

Summary

This document outlines the Automate implementation of the agnostic script Set-PowerPlan, which can be used to modify or create a power plan.

The settings for the power plan are required to create or modify the power plan. These settings can be provided to the script in two ways: through the Settings parameter as a hash table or from a CSV file. A template for the CSV file is attached to this document. Details regarding the columns of the CSV file are explained later in this document.

Sample Run (Set Environment)

Run the script with the Set_Environment parameter set to 1 to create the EDFs used by the script and the PowerPlan Automation internal monitor.

Sample Run

Sample Run (Manual)

Example 1: Saving the CSV file for the Power Settings in the LTShare (WebDav for the hosted partners)

  • This is the recommended method for running this script.
  • Download the attached PowerPlanSettingsTemplate.CSV file from this document.
  • Edit the downloaded file.
  • Specify the necessary values for the power settings in the Direct Power Settings (AC) and Battery Power Settings (DC) columns.
  • For rows where the Minimum Possible Setting and Maximum Possible Setting columns have values, ensure that the values in the Direct Power Settings (AC) and Battery Power Settings (DC) columns fall within the specified range.
  • For rows where the Possible Settings column has a value, input the numerical value for both Direct Power Settings (AC) and Battery Power Settings (DC) columns, as described in the Possible Settings column.
  • Refrain from modifying any columns other than the Direct Power Setting (AC) and Direct Power Setting (DC) columns.
  • Keep the first row of the CSV file unchanged.

CSV Example

  • Rename the file to a name relevant to the PowerProfile you intend to create or edit.
  • In this example, I am renaming it to Test_Power_Plan as I will be creating a power plan named Test Power Plan on the machine.
  • Place the file in the LTShare (WebDav for hosted partners) within the Transfer/PowerPlan directory. If the PowerPlan directory doesn't exist under the Transfer directory, you may need to create it.

Directory Example

  • Alternatively, you can use the ProVal_-_High_Performance.csv file. It's a pre-created power profile equivalent to the Windows default High Performance.
  • Run the script on the relevant machine(s) with the specified parameters to create the Test Power Plan with the power settings outlined in the CSV file Test_Power_Plan:

PowerPlan: Test Power Plan
CSVPath: Test_Power_Plan

Run Example

Example 2: Placing the CSV file in a downloadable location other than LTShare.

  • This method can be used if the CSV file cannot be placed in the LTShare but can be placed at another downloadable location.
  • Edit and rename the CSV file as explained in Example 1.
  • Place the file at a location from where it can be downloaded using a download URL.
  • I have placed the file at https://file.provaltech.com, and the download URL is https://file.provaltech.com/repo/powerplan/Test_Power_Plan.csv. (This is a dummy download URL used in this example to demonstrate how a download URL to download the CSV file should look.)
  • Run the script on the relevant machine(s) with the specified parameters to create the Test Power Plan with the power settings outlined in the CSV file Test_Power_Plan:

PowerPlan: Test Power Plan
CSVPath: https://file.provaltech.com/repo/powerplan/Test_Power_Plan.csv

Download Example

Example 3: Using HashTable

  • This approach is suitable for updating a selected number of settings within a power plan.
  • Proficiency in PowerShell's hash table is crucial to utilize this method effectively.
  • In this method, the power settings are supplied to the script through the Settings parameter, employing a correctly formatted hash table of the settings.

Format of the Hash Table:

@{Subgroup=@{'<Name of the Subgroup>' = @{ <strong>PowerSetting </strong>= @{ '<Name of the Power Setting>' = @{ AC = <Value of the setting on Direct Power>; DC = <Value of the Setting on Battery Power> }; 'Name of the Power Setting' = @{ AC = <Value of the setting on Direct Power>; DC = <Value of the Setting on Battery Power>}; '<Name of the Power Setting>' = @{ AC = <Value of the setting on Direct Power>; DC = <Value of the Setting on Battery Power>}; '<Name of the Power Setting>' = @{ AC = <Value of the setting on Direct Power>; DC = <Value of the Setting on Battery Power> }}}}}

Ensure that the name of the subgroup and the power settings match those specified in the attached CSV file. The values for both AC and DC should fall within the range defined in the CSV file or be selected from the possible settings if the range does not apply to the setting.

In this example, I am configuring the values for the following settings within the Test Power Plan:

@{Subgroup=@{'Sleep' = @{ PowerSetting = @{ 'Sleep after' = @{ AC = 60; DC = 60 }; 'Allow hybrid sleep' = @{ AC = 1; DC = 100}; 'Hibernate After' = @{ AC = 0; DC = 18000}; 'Allow Wake Timers' = @{ AC = 2; DC = 2 }}}}}

If the power plan named Test Power Plan doesn't already exist on the computer, the script will create it with the settings outlined in the table below while the rest of the settings will be copied from the currently active power plan. Otherwise, if the plan already exists, only the following settings will be modified.

SubgroupPower SettingDirect Power Settings (AC)Battery Power Settings (DC)
SleepSleep after6060
SleepAllow hybrid sleep1100
SleepHibernate After018000
SleepAllow Wake Timers22

Run the script on the relevant machine(s) with the specified parameters to create/modify the Test Power Plan with the power settings outlined in the Setting parameter:

PowerPlan: Test Power Plan
Setting:

@{Subgroup=@{'Sleep' = @{ PowerSetting = @{ 'Sleep after' = @{ AC = 60; DC = 60 }; 'Allow hybrid sleep' = @{ AC = 1; DC = 100}; 'Hibernate After' = @{ AC = 0; DC = 18000}; 'Allow Wake Timers' = @{ AC = 2; DC = 2 }}}}}

Run Configuration

See the agnostic script's documentation for additional examples.

Automation

  • Edit and place the configuration file in the LTShare (WebDav for hosted partners) within the Transfer/PowerPlan directory as described in Example 1 of the Sample Run (Manual) section. Alternatively, you can use the ProVal_-_High_Performance.csv file. It's a pre-created power profile equivalent to the Windows default High Performance.

Automation Example

  • Set the appropriate option in the Client-Level EDF PowerPlan Automation to enable it for the client's machines. Leaving it blank is equivalent to setting it to Not Enabled.

Client-Level EDF

  • Set the name of the CSV file placed in the LTShare to the PowerPlan Configuration File EDF.

CSV Name Example

  • Set the name of the PowerPlan to the PowerPlan Name EDF. This name will be displayed for the plan at the end machine and can be anything.

PowerPlan Name Example

Note:

  • In the example demonstrated above, the ProVal High Performance power plan will be set and enabled on all workstations of the Development client.
  • The PowerPlan Automation internal monitor should be running for the automation to work.

PowerPlanSettingsTemplate.CSV

The provided CSV file acts as the template for the settings accepted by the script for creating or modifying the power plan. To use it effectively, download and modify the template to specify the CSVPath parameter, as illustrated in the aforementioned examples.

Here's a breakdown of the columns in the CSV file:

Subgroup: Displays the name of the subgroups of the power plan. This column should not be edited or modified.

Power Setting: Indicates the name of the associated power setting for that subgroup. This column should not be edited or modified.

Direct Power Settings (AC): Stores the value for the power setting when the machine is connected directly to electricity. Update this column as required.

Battery Power Setting (DC): Stores the value for the power setting when the machine is running on battery/UPS power. Update this column as required.

Minimum Possible Setting: Specifies the minimum value that can be set for the Direct Power Settings (AC) and Battery Power Settings (DC) columns. Applicable for rows where a value is present in this column. Do not edit or modify this column.

Maximum Possible Setting: Defines the maximum value that can be set for the Direct Power Settings (AC) and Battery Power Settings (DC) columns. Applicable for rows where a value is present in this column. Do not edit or modify this column.

Possible Settings: Explains the values that can be set for the Direct Power Settings (AC) and Battery Power Settings (DC) columns. Applicable for rows where a value is present in this column. Do not edit or modify this column.

Additional Notes: Offers additional explanations, particularly when 0 signifies never for rows where such interpretation is relevant.

Note: To understand the relation of the columns in the CSV file with the power plan settings, you can run the powercfg /query command from the command prompt. This command will display detailed information about the power plans configured on your Windows computer, including their settings. By examining the output of this command, you can correlate the settings listed with the columns in the CSV file, such as subgroup names, power setting names, and their corresponding values for AC and DC power sources.

Dependencies

Variables

NameDescription
ProjectNameSet-PowerPlan
WorkingDirectoryC:/ProgramData/_Automation/Script/Set-PowerPlan

User Parameters

NameExampleRequiredDescription
PowerPlanTest Power PlanTrueName of the power plan to modify or create.
Setting@{Subgroup=@{'Sleep' = @{ PowerSetting = @{ 'Sleep after' = @{ AC = 60; DC = 60 }; 'Allow hybrid sleep' = @{ AC = 1; DC = 100}; 'Hibernate After' = @{ AC = 0; DC = 18000}; 'Allow Wake Timers' = @{ AC = 2; DC = 2 }}}}}PartiallyHash table of the power plan settings to set.
CSVPathhttps://file.provaltech.com/repo/powerplan/Test_Power_Plan.csv (if the CSV file of the settings is placed at a downloadable location) OR Test_Power_Plan (if the CSV file of the settings is placed in the LTShare (WebDav for the hosted partners) under the Transfer/PowerPlan directory)PartiallyDownload URL of the CSV file if the file is placed at a downloadable location. OR Name of the CSV file if the file is placed in the LTShare (WebDav for the hosted partners) under the Transfer/PowerPlan directory.
Set_Environment1For the first runRun the script with the Set_Environment parameter set to 1 to create the EDFs used by the script and the PowerPlan Automation internal monitor.

Client-Level EDF

NameExampleTypeSectionDescription
PowerPlan Automation1/0DropdownPowerPlanSet the appropriate option in Client-Level EDF PowerPlan Automation to enable it for the client's machines. Available Options:
  • Not Enabled
  • Enabled for Workstations Only
  • Enabled for Laptops Only
  • Enabled for Servers Only
  • Enabled for All Machines
PowerPlan Configuration FileProVal_-_High_PerformanceTextPowerPlanSet the name of the CSV file placed in the LTShare to the PowerPlan Configuration File EDF.
PowerPlan NameProVal High PerformanceTextPowerPlanSet the name of the PowerPlan to the PowerPlan Name EDF. This name will be displayed for the plan at the end machine and can be anything.

Client-Level EDF Example

Computer-Level EDF

NameExampleTypeSectionDescription
PowerPlan Automation Exclusion1/0Check BoxExclusionsMark this EDF to exclude the computer from the PowerPlan automation.

Output

  • Script Log
  • Custom Table

Attachments

PowerPlanSettingsTemplate.csv
ProVal_-_High_Performance.csv