PowerShell Script – Set-PowerCfg

Set-PowerCfg is a simple script that can be used to easily set or check the current power scheme being applied on a Windows host, these are the same settings found in Control Panel > Power Options.

This is particularly useful on laptops where CPU throttling may be an issue and you need to easily switch between power profiles, ie plugged in vs running on battery. If you are not familiar with this particular issue, please see below for more information.

The script is menu driven, just run it and select a menu option.

Usage:
./Set-PowerCfg.ps1

The most current version of the script can be found in my GitHub repo:
https://github.com/robwillisinfo/Set-PowerCfg

Screen shot:

Why is this important?

Most modern CPUs have power saving features (like Intels SpeedStep) that allow the operating system to dynamically down clock the CPU frequency when the load is light and when the load increases the CPU frequency should increase. This has some advantages like lower energy consumption, less heat generation and more importantly it can really help with battery life.

This all sounds pretty good, what could possibly go wrong? Unfortunately, some times the CPU does not properly ramp back up and gets stuck at the lower frequency, which can lead to poor performance even on higher end hardware. It’s not just laptops and desktops that have this issue either, I’ve seen brand new multi CPU server hardware running something like MS SQL Server that can put a lot of stress on all of the hardware involved and the server just completely fall apart under load for this exact reason.

There are mainly two places to control these settings, in the BIOS and in Windows. Most of the time the BIOS settings just forward control to the OS, and on Windows these settings are controlled via Power Options in the Control Panel.

Here is a quick screen shot of my Dell Precision M3800 running in “Balanced” vs “High Performance” mode, notice the huge jump in the speed of the CPU as it is now running at full speed plus the full Turbo Boost:

With this script, I can now easily switch to high performance when I am docked and in “desktop mode” trying to squeeze out every ounce of performance I can, then when I am on the go and running off the battery I can switch it back to balanced or power saver to get the most out of the charge without having to dig through the Control Panel.

Comments are closed.