set-powerplan.ps1 529 Bytes
Newer Older
1
Try {
2 3
  Write-Output "Set power plan to high performance"

4
  $HighPerf = powercfg -l | %{if($_.contains("High performance")) {$_.split()[3]}}
5 6 7 8 9 10 11 12

  # $HighPerf cannot be $null, we try activate this power profile with powercfg
  # 
  if ($HighPerf -eq $null)
  {
    throw "Error: HighPerf is null"
  }

13
  $CurrPlan = $(powercfg -getactivescheme).split()[3]
14

15
  if ($CurrPlan -ne $HighPerf) {powercfg -setactive $HighPerf}
16

17 18
} Catch {
  Write-Warning -Message "Unable to set power plan to high performance"
19
  Write-Warning $Error[0]
20
}