# Setting Ultimate Performance power plan # The hidden template GUID for Ultimate Performance $templateGUID = "e9a42b02-d5df-448d-aa00-03f14749eb61" $planName = "Ultimate Performance" # 2. Check if the plan already exists to prevent duplicates $existingCheck = powercfg /list | Select-String -Pattern $planName if ($existingCheck) { # --- SCENARIO A: Plan already exists --- Write-Host "Plan already exists. finding existing GUID..." -ForegroundColor Yellow # Extract GUID from the existing list entry if ($existingCheck.ToString() -match '([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})') { $targetGUID = $matches[0] } } else { # --- SCENARIO B: Create new plan and capture output --- Write-Host "Creating Ultimate Performance plan..." -ForegroundColor Cyan # Run the command and capture the output string $output = powercfg -duplicatescheme $templateGUID 2>&1 # $output will look like: "Power Scheme GUID: xxxxxxxx-xxxx... (Ultimate Performance)" # We use regex to pull the GUID specifically from this output if ($output -match '([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})') { $targetGUID = $matches[0] Write-Host "Created with GUID: $targetGUID" -ForegroundColor Green } else { Write-Error "Failed to extract GUID from creation output." Exit } } # 3. Set the plan as active if ($targetGUID) { powercfg -setactive $targetGUID Write-Host "Successfully activated Ultimate Performance ($targetGUID)" -ForegroundColor Green } #Set Power Options Write-Host -ForegroundColor Green "Set Power options" powercfg.exe -change -monitor-timeout-ac 0 powercfg.exe -change -monitor-timeout-dc 0 powercfg.exe -change -disk-timeout-ac 0 powercfg.exe -change -disk-timeout-dc 0 powercfg.exe -change -standby-timeout-ac 0 powercfg.exe -change -standby-timeout-dc 0 powercfg.exe -change -hibernate-timeout-ac 0 powercfg.exe -change -hibernate-timeout-dc 0