Temporarily Activate High Performance Power Plan

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus

13 Free SQL Tools from Idera

Free Ebook: Mastering Powershell


It may be useful to automatically and temporarily switch to a "high performance" power plan from inside a script. Maybe you know that a script has to do CPU-intensive tasks, and you would like to speed it up a bit.

Here is how a script can change power plan settings:

# save current power plan:
$PowerPlan = (Get-WmiObject -Name root\cimv2\power -Class Win32_PowerPlan -Filter 'isActive=True').ElementName
"Current Power Plan: $PowerPlan"

# turn on high performance power plan:
(Get-WmiObject -Name root\cimv2\power -Class Win32_PowerPlan -Filter 'ElementName="High Performance"').Activate()

# do something 
"Power Plan now is High Performance!"
Start-Sleep -Seconds 3

# turn power plan back to what it was before:
(Get-WmiObject -Name root\cimv2\power -Class Win32_PowerPlan -Filter "ElementName='$PowerPlan'").Activate()
"Power Plan is back to $PowerPlan"

Twitter This Tip! ReTweet this Tip!

Posted Mar 06 2013, 06:00 AM by ps1
Copyright 2012 PowerShell.com. All rights reserved.