This PowerShell script, smartperformance.ps1
, aims to automatically switch between the Balanced and High Performance power plans on your Windows machine based on whether your device is connected to a power source or running on battery.
- Automatically switches between Balanced and High Performance power plans.
- Monitors power events in real-time.
- Lightweight and easy to use.
- Windows OS with PowerShell installed.
- PowerShell 5.1 or later.
- Clone or download the script file
smartperformance.ps1
. - Open PowerShell with Administrator privileges.
- Navigate to the folder containing the script.
- Run the script by typing
.\smartperformance.ps1
and pressing Enter. - The script will start monitoring power events and switch power plans accordingly. Press Ctrl+C to exit.
-
Right-click on an empty space on your desktop or desired folder, then click on
New > Shortcut
. -
In the
Create Shortcut
window, type the following in theType the location of the item
field:powershell.exe -ExecutionPolicy Bypass -File "C:\path\to\smartperformance.ps1" ``` Replace `C:\path\to\` with the actual path to the folder containing the `smartperformance.ps1` script.
-
Click
Next
, give your shortcut a name (e.g., "Smart Performance Switcher"), and clickFinish
. -
Now, right-click on the newly created shortcut and click on
Properties
. -
In the
Shortcut
tab, click on theAdvanced
button. -
Check the box next to
Run as administrator
, then clickOK
. -
Click
Apply
, then clickOK
to close theProperties
window.
Now, when you double-click on the shortcut, the smartperformance.ps1
script will be executed as Administrator.
- The script defines GUIDs for the Balanced and High Performance power plans.
- Functions are defined to get the current power plan, set a new power plan, and check the power status.
- An event is registered for power management events to detect when the power source changes.
- The script sets the initial power plan based on the current power status and starts monitoring power events.
This project is licensed under the MIT License. See the LICENSE file for details.