Skip to content

MSWindows – powercfg – maximum peformance profile

cpx September 23, 2026 3 min read MSWindows (MSFT)
powershell
<#
.SYNOPSIS
    Creates and activates a "Maximum Performance" power plan with tuned settings.

.DESCRIPTION
    Duplicates the hidden Ultimate Performance scheme (falls back to High Performance
    if Ultimate is not available on this edition), renames it, applies performance
    tuning, and sets it active. Run from an elevated PowerShell prompt.

.PARAMETER IncludeBattery
    Also apply performance values on battery (DC). Off by default to protect laptop battery life.

.PARAMETER MonitorTimeoutMinutes
    Display off timeout on AC. Does not affect performance. Default 15. Use 0 for never.

.PARAMETER DisableHibernate
    Turns hibernation off completely (removes hiberfil.sys and Fast Startup).

.PARAMETER Revert
    Switches back to Balanced and deletes the Maximum Performance plan.

.EXAMPLE
    .\Set-MaxPerformance.ps1
    .\Set-MaxPerformance.ps1 -IncludeBattery -DisableHibernate
    .\Set-MaxPerformance.ps1 -Revert
#>
[CmdletBinding()]
param(
    [switch]$IncludeBattery,
    [int]$MonitorTimeoutMinutes = 15,
    [switch]$DisableHibernate,
    [switch]$Revert
)

$ErrorActionPreference = 'Stop'
$PlanName      = 'Maximum Performance'
$UltimateGuid  = 'e9a42b02-d5df-448d-aa00-03f14749eb61'
$HighPerfGuid  = '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c'
$BalancedGuid  = '381b4222-f694-41f0-9685-ff5bb260df2e'

# --- Admin check ---------------------------------------------------------------
$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    Write-Error 'Run this script from an elevated (Administrator) PowerShell prompt.'
    exit 1
}

# --- Helpers -------------------------------------------------------------------
function Get-PlanGuidByName([string]$Name) {
    $line = powercfg /list | Where-Object { $_ -match [regex]::Escape("($Name)") } | Select-Object -First 1
    if ($line -match '([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})') { return $Matches[1] }
    return $null
}

function Set-PowerValue([string]$Plan, [string]$Sub, [string]$Setting, [int]$Value, [string]$Label) {
    powercfg /setacvalueindex $Plan $Sub $Setting $Value 2>&1 | Out-Null
    $acOk = ($LASTEXITCODE -eq 0)
    if ($IncludeBattery) {
        powercfg /setdcvalueindex $Plan $Sub $Setting $Value 2>&1 | Out-Null
    }
    if ($acOk) { Write-Host ("  [OK]   {0} = {1}" -f $Label, $Value) -ForegroundColor Green }
    else       { Write-Host ("  [SKIP] {0} (not supported on this hardware)" -f $Label) -ForegroundColor Yellow }
}

# --- Revert --------------------------------------------------------------------
if ($Revert) {
    powercfg /setactive $BalancedGuid
    $existing = Get-PlanGuidByName $PlanName
    if ($existing) { powercfg /delete $existing; Write-Host "Deleted plan '$PlanName'." }
    Write-Host 'Balanced plan is active again.' -ForegroundColor Cyan
    exit 0
}

# --- Remove previous copy so the script is safe to rerun -------------------------
$existing = Get-PlanGuidByName $PlanName
if ($existing) {
    powercfg /setactive $BalancedGuid
    powercfg /delete $existing
    Write-Host "Removed previous '$PlanName' plan."
}

# --- Create plan -----------------------------------------------------------------
$out = powercfg /duplicatescheme $UltimateGuid 2>&1
if ($LASTEXITCODE -ne 0 -or -not ($out -match '([0-9a-fA-F-]{36})')) {
    Write-Host 'Ultimate Performance not available, using High Performance as base.' -ForegroundColor Yellow
    $out = powercfg /duplicatescheme $HighPerfGuid 2>&1
    if (-not ($out -match '([0-9a-fA-F-]{36})')) { Write-Error "Could not duplicate a base scheme: $out"; exit 1 }
}
$Plan = $Matches[1]
powercfg /changename $Plan $PlanName 'Tuned for maximum performance'
Write-Host "Created '$PlanName' ($Plan)" -ForegroundColor Cyan
Write-Host 'Applying settings:'

# --- Processor -------------------------------------------------------------------
Set-PowerValue $Plan SUB_PROCESSOR PROCTHROTTLEMIN 100 'CPU minimum state (%)'
Set-PowerValue $Plan SUB_PROCESSOR PROCTHROTTLEMAX 100 'CPU maximum state (%)'
Set-PowerValue $Plan SUB_PROCESSOR PERFBOOSTMODE   2   'Turbo boost mode (2 = Aggressive)'
Set-PowerValue $Plan SUB_PROCESSOR CPMINCORES      100 'Core parking min cores (%)'
Set-PowerValue $Plan SUB_PROCESSOR PERFEPP         0   'Energy performance preference (0 = performance)'

# --- Storage, PCIe, USB, Wi-Fi ---------------------------------------------------
Set-PowerValue $Plan SUB_DISK        DISKIDLE 0 'Hard disk turn off after (0 = never)'
Set-PowerValue $Plan SUB_PCIEXPRESS  ASPM     0 'PCIe link state power management (0 = off)'
Set-PowerValue $Plan 2a737441-1930-4402-8d77-b2bebba308a3 48e6b7a6-50f5-4782-a5d4-53bb8f07e226 0 'USB selective suspend (0 = disabled)'
Set-PowerValue $Plan 19cbb8fa-5279-450e-9fac-8a3d5fedd0c1 12bbebe6-58d6-4636-95bb-3217ef867c1a 0 'Wireless adapter (0 = max performance)'

# --- Sleep and display -----------------------------------------------------------
Set-PowerValue $Plan SUB_SLEEP STANDBYIDLE   0 'Sleep after (0 = never)'
Set-PowerValue $Plan SUB_SLEEP HIBERNATEIDLE 0 'Hibernate after (0 = never)'
Set-PowerValue $Plan SUB_VIDEO VIDEOIDLE ($MonitorTimeoutMinutes * 60) 'Display off after (seconds)'

# --- Activate --------------------------------------------------------------------
powercfg /setactive $Plan

if ($DisableHibernate) {
    powercfg /hibernate off
    Write-Host '  [OK]   Hibernation disabled' -ForegroundColor Green
}

Write-Host ''
Write-Host 'Active plan:' -ForegroundColor Cyan
powercfg /getactivescheme
if (-not $IncludeBattery) { Write-Host 'Note: battery (DC) values left at plan defaults. Use -IncludeBattery to change them.' }

Be the first to comment

protected · no tracking

0 comments