mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 09:20:36 -06:00
Removed the GUID.txt for a local variable
This commit is contained in:
parent
09fed571b7
commit
71173740ae
@ -1,43 +1,25 @@
|
||||
# PowerShell script to fix the power plan applied across all languages based on the GUID of the new power plan.
|
||||
# This is necessary because when Windows is in a different language, the power plan might not be applied correctly.
|
||||
# This script changes the name and description of the power plan.
|
||||
#Video : https://youtu.be/00aUECZNvbA
|
||||
|
||||
# ID of the plan to duplicate
|
||||
$sourceGUID = "e9a42b02-d5df-448d-aa00-03f14749eb61"
|
||||
$guid = $null
|
||||
$nameFromFile = "ChrisTitus - Ultimate Power Plan"
|
||||
$description = "Ultimate Power Plan , added via WinUtils"
|
||||
|
||||
$scriptPath = $MyInvocation.MyCommand.Path
|
||||
$directoryPath = Split-Path -Path $scriptPath -Parent
|
||||
|
||||
$guidFilePath = Join-Path -Path $directoryPath -ChildPath "guid.txt"
|
||||
|
||||
# Duplicate the power plan
|
||||
$duplicateOutput = powercfg /duplicatescheme $sourceGUID
|
||||
|
||||
try {
|
||||
$duplicateOutput | Out-File -FilePath $guidFilePath -Append -Encoding utf8 -Force
|
||||
$guid = $null
|
||||
$nameFromFile = "ChrisTitus - Ultimate Power Plan"
|
||||
$description = "Ultimate Power Plan, added via WinUtils"
|
||||
|
||||
Write-Output "The output of 'powercfg /duplicatescheme' has been added to $guidFilePath."
|
||||
} catch {
|
||||
Write-Error "Error writing to the file: $_"
|
||||
}
|
||||
$content = Get-Content -Path $guidFilePath -Encoding utf8
|
||||
|
||||
# Extract the GUID from the content
|
||||
foreach ($line in $content) {
|
||||
# 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 the GUID to guid.txt (overwrite existing content)
|
||||
$guid | Out-File -FilePath $guidFilePath -Encoding utf8 -Force
|
||||
|
||||
Write-Output "GUID: $guid has been saved to $guidFilePath"
|
||||
Write-Output "GUID: $guid has been extracted and stored in the variable."
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $guid) {
|
||||
Write-Output "No GUID found in $guidFilePath. Check the content format."
|
||||
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
|
||||
@ -53,7 +35,7 @@ try {
|
||||
Write-Output "The power plan has been set as active. Output:"
|
||||
Write-Output $setActiveOutput
|
||||
} else {
|
||||
Write-Output "GUID is missing. Ensure that guid.txt contains the necessary information."
|
||||
Write-Output "GUID is missing. Ensure that the GUID was properly extracted."
|
||||
}
|
||||
} catch {
|
||||
Write-Error "Error executing powercfg commands: $_"
|
||||
|
Loading…
Reference in New Issue
Block a user