I am running my new notebook computer with the following power plan, which specifies that the machine shuts down after one hour of idleness:

However, I do not want the machine powering-down when a long-running backup is running. To solve this problem:

SetPowerPlan.ps1:
param($PreferredPlan)
function SetPowerPlan([string]$PreferredPlan)
{
Write-Host "Setting Powerplan to $PreferredPlan"
$guid = (Get-WmiObject -Class win32_powerplan -Namespace root\cimv2\power -Filter "ElementName='$PreferredPlan'").InstanceID.tostring()
$regex = [regex]"{(.*?)}$"
$newpowerVal = $regex.Match($guid).groups[1].value
# setting power setting to high performance
powercfg -S $newpowerVal
}
SetPowerPlan $PreferredPlan
Backup.ps1:
... & C:\PSScripts\SetPowerPlan.ps1 "Custom_Always_On" ... # code for potentially long-running backup ... & C:\PSScripts\SetPowerPlan.ps1 "Custom_Auto_Power_Down" ...
Now there is no risk of the machine powering-down in the middle of a long backup.
Use PowerShell to control your computer's power utilization
| Title | Date |
| Node.js + Express: How to Block Requests by User-Agent Headers | January 7, 2026 |
| Vault 3 is Now Available for Windows on ARM Machines! | December 13, 2025 |
| Vault 3: How to Include Outline Text in Exported Photos | October 26, 2025 |
| .NET Public-Key (Asymmetric) Cryptography Demo | July 20, 2025 |
| Raspberry Pi 3B+ Photo Frame | June 17, 2025 |
| EBTCalc (Android) Version 1.53 is now available | May 19, 2024 |
| Vault 3 Security Enhancements | October 24, 2023 |