2023-03-07 14:28:00 -06:00
|
|
|
Function Invoke-WPFUltimatePerformance {
|
|
|
|
<#
|
2023-10-19 17:12:55 -05:00
|
|
|
|
|
|
|
.SYNOPSIS
|
|
|
|
Creates or removes the Ultimate Performance power scheme
|
|
|
|
|
|
|
|
.PARAMETER State
|
|
|
|
Indicates whether to enable or disable the Ultimate Performance power scheme
|
|
|
|
|
2023-03-07 14:28:00 -06:00
|
|
|
#>
|
|
|
|
param($State)
|
|
|
|
Try{
|
2024-07-08 15:22:26 -05:00
|
|
|
# Check if Ultimate Performance plan is installed
|
|
|
|
$ultimatePlan = powercfg -list | Select-String -Pattern "Ultimate Performance"
|
|
|
|
if($state -eq "Enable"){
|
|
|
|
if ($ultimatePlan) {
|
|
|
|
Write-Host "Ultimate Performance plan is already installed."
|
|
|
|
} else {
|
|
|
|
Write-Host "Installing Ultimate Performance plan..."
|
|
|
|
powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61
|
|
|
|
Write-Host "> Ultimate Performance plan installed."
|
2023-10-19 17:12:55 -05:00
|
|
|
}
|
2023-05-16 14:52:11 -05:00
|
|
|
|
2024-07-08 15:22:26 -05:00
|
|
|
# Set the Ultimate Performance plan as active
|
|
|
|
$ultimatePlanGUID = (powercfg -list | Select-String -Pattern "Ultimate Performance").Line.Split()[3]
|
|
|
|
powercfg -setactive $ultimatePlanGUID
|
2023-10-19 17:12:55 -05:00
|
|
|
|
2024-07-08 15:22:26 -05:00
|
|
|
Write-Host "Ultimate Performance plan is now active."
|
2023-10-19 17:12:55 -05:00
|
|
|
|
2023-05-16 14:52:11 -05:00
|
|
|
|
2024-07-08 15:22:26 -05:00
|
|
|
}
|
|
|
|
elseif($state -eq "Disable"){
|
|
|
|
if ($ultimatePlan) {
|
|
|
|
# Extract the GUID of the Ultimate Performance plan
|
|
|
|
$ultimatePlanGUID = $ultimatePlan.Line.Split()[3]
|
2024-07-16 14:02:31 -05:00
|
|
|
|
2024-07-08 15:22:26 -05:00
|
|
|
# Set a different power plan as active before deleting the Ultimate Performance plan
|
|
|
|
$balancedPlanGUID = (powercfg -list | Select-String -Pattern "Balanced").Line.Split()[3]
|
|
|
|
powercfg -setactive $balancedPlanGUID
|
|
|
|
|
|
|
|
# Delete the Ultimate Performance plan
|
|
|
|
powercfg -delete $ultimatePlanGUID
|
|
|
|
|
|
|
|
Write-Host "Ultimate Performance plan has been uninstalled."
|
|
|
|
Write-Host "> Balanced plan is now active."
|
|
|
|
} else {
|
|
|
|
Write-Host "Ultimate Performance plan is not installed."
|
2023-05-16 14:52:11 -05:00
|
|
|
}
|
2024-07-08 15:22:26 -05:00
|
|
|
}
|
|
|
|
} Catch{
|
2023-03-07 14:28:00 -06:00
|
|
|
Write-Warning $psitem.Exception.Message
|
|
|
|
}
|
2024-07-08 15:22:26 -05:00
|
|
|
}
|