Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request the Ultimate Power Plan in the Tweaks tab. #2549

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions utilmatepowerplan-fix.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# ID of the plan to duplicate
$sourceGUID = "e9a42b02-d5df-448d-aa00-03f14749eb61"

# Duplicate the power plan
$duplicateOutput = powercfg /duplicatescheme $sourceGUID

$guid = $null
$nameFromFile = "ChrisTitus - Ultimate Power Plan"
$description = "Ultimate Power Plan, added via WinUtils"

# Extract the GUID directly from the duplicateOutput
foreach ($line in $duplicateOutput) {
if ($line -match "GUID du mode de gestion de l'alimentation\s*:\s*([a-fA-F0-9\-]+)") {
$guid = $matches[1]
Write-Output "GUID: $guid has been extracted and stored in the variable."
break
}
}

if (-not $guid) {
Write-Output "No GUID found in the duplicateOutput. Check the output format."
exit 1
}

# Execute commands to change the plan name and set the plan as active
try {
if ($guid) {
# Change the name of the power plan and set its description
$changeNameOutput = powercfg /changename $guid "$nameFromFile" "$description"
Write-Output "The power plan name and description have been changed. Output:"
Write-Output $changeNameOutput

# Set the power plan as active
$setActiveOutput = powercfg /setactive $guid
Write-Output "The power plan has been set as active. Output:"
Write-Output $setActiveOutput
} else {
Write-Output "GUID is missing. Ensure that the GUID was properly extracted."
}
} catch {
Write-Error "Error executing powercfg commands: $_"
}