mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-12 08:03:51 -05:00
Compare commits
2 Commits
24.10.24
...
71173740ae
Author | SHA1 | Date | |
---|---|---|---|
71173740ae | |||
09fed571b7 |
42
utilmatepowerplan-fix.ps1
Normal file
42
utilmatepowerplan-fix.ps1
Normal file
@ -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: $_"
|
||||
}
|
Reference in New Issue
Block a user