WIN-021 · Script
Power Plan Configuration
Reports and sets the power plan, screen, sleep, hibernate and lid close actions for desktops or laptops.
What it does
Uses the built-in powercfg tool to read and change the active power plan. Values can come from a preset, from individual parameters, or both (individual values override the preset).
Presets:
- None: Only the individual parameters you set are applied (default)
Desktop Screen off after 15 minutes, never sleep or hibernate on AC power. Suits lab and office desktops that need to stay reachable for overnight maintenance.
- Laptop: Plugged in: screen 10, sleep 30, hibernate never, lid closes = sleep.
On battery: screen 5, sleep 15, hibernate 120, lid closes = sleep.
- Auto: Picks Laptop when the device has a battery or a portable chassis, otherwise Desktop.
Timeouts are in minutes. 0 = never. -1 (default) = leave the current value unchanged. Report mode (default) shows the current values and what Apply would change. Apply mode changes the settings on the active plan. Group Policy or MDM power settings take precedence over local settings and may undo changes. Runs silently as SYSTEM. No prompts.
Requirements
Windows PowerShell 5.1+, run as SYSTEM or local admin
How to run it
- Run as: SYSTEM or a local administrator
- Run from: any RMM or MDM, Intune, a Group Policy startup script, a scheduled task, or an elevated PowerShell window
- Script type: PowerShell, 64-bit
- User interaction: none; the script never prompts
- Timeout: 10 minutes (30 for Windows Update installs)
Settings
| Name | What it does | Options | Default |
|---|---|---|---|
| Mode | Report (default) = show current and planned values. Apply = change them. | Report, Apply | Report |
| Preset | None (default), Desktop, Laptop or Auto. | None, Desktop, Laptop, Auto | None |
| PowerPlan | Unchanged (default), Balanced, HighPerformance or PowerSaver. Switches the active plan first. | Unchanged, Balanced, HighPerformance, PowerSaver | Unchanged |
| MonitorAcMinutes | Turn off the screen after this many minutes on AC power. 0 = never, -1 = unchanged. | -1 | |
| MonitorDcMinutes | Turn off the screen after this many minutes on battery. 0 = never, -1 = unchanged. | -1 | |
| SleepAcMinutes | Sleep after this many minutes on AC power. 0 = never, -1 = unchanged. | -1 | |
| SleepDcMinutes | Sleep after this many minutes on battery. 0 = never, -1 = unchanged. | -1 | |
| HibernateAcMinutes | Hibernate after this many minutes on AC power. 0 = never, -1 = unchanged. | -1 | |
| HibernateDcMinutes | Hibernate after this many minutes on battery. 0 = never, -1 = unchanged. | -1 | |
| LidActionAc | What closing the lid does on AC power: Unchanged (default), Nothing, Sleep, Hibernate or ShutDown. | Unchanged, Nothing, Sleep, Hibernate, ShutDown | Unchanged |
| LidActionDc | What closing the lid does on battery: Unchanged (default), Nothing, Sleep, Hibernate or ShutDown. | Unchanged, Nothing, Sleep, Hibernate, ShutDown | Unchanged |
| Hibernate | Unchanged (default), On or Off. Turns the hibernate feature itself on or off (powercfg /hibernate). | Unchanged, On, Off | Unchanged |
Exit codes
- 0 = Settings already match, or changes applied
- 1 = Report: changes needed. Apply: one or more settings could not be set
- 2 = Script error
Testing steps
- Run it first with the mode set to Report on one test device. Nothing is changed in that mode.
- Read the log and confirm the planned changes are what you expect.
- Run your chosen settings on the same test target and confirm the result.
- Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
- Roll out to a small group next, then everyone.
Rollback steps
Report mode logs the current values before any change. Run the script again with -Mode Apply and those values (for example -SleepAcMinutes 30 -LidActionAc Sleep), or reset the plan to Windows defaults with powercfg /restoredefaultschemes.
Version and change log
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | November 2026 | First release. |