Library / Windows endpoint

WIN-021 · Script

Power Plan Configuration

Reports and sets the power plan, screen, sleep, hibernate and lid close actions for desktops or laptops.

Version 1.0.0Language PowerShellUpdated November 2026

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

NameWhat it doesOptionsDefault
ModeReport (default) = show current and planned values. Apply = change them.Report, ApplyReport
PresetNone (default), Desktop, Laptop or Auto.None, Desktop, Laptop, AutoNone
PowerPlanUnchanged (default), Balanced, HighPerformance or PowerSaver. Switches the active plan first.Unchanged, Balanced, HighPerformance, PowerSaverUnchanged
MonitorAcMinutesTurn off the screen after this many minutes on AC power. 0 = never, -1 = unchanged.-1
MonitorDcMinutesTurn off the screen after this many minutes on battery. 0 = never, -1 = unchanged.-1
SleepAcMinutesSleep after this many minutes on AC power. 0 = never, -1 = unchanged.-1
SleepDcMinutesSleep after this many minutes on battery. 0 = never, -1 = unchanged.-1
HibernateAcMinutesHibernate after this many minutes on AC power. 0 = never, -1 = unchanged.-1
HibernateDcMinutesHibernate after this many minutes on battery. 0 = never, -1 = unchanged.-1
LidActionAcWhat closing the lid does on AC power: Unchanged (default), Nothing, Sleep, Hibernate or ShutDown.Unchanged, Nothing, Sleep, Hibernate, ShutDownUnchanged
LidActionDcWhat closing the lid does on battery: Unchanged (default), Nothing, Sleep, Hibernate or ShutDown.Unchanged, Nothing, Sleep, Hibernate, ShutDownUnchanged
HibernateUnchanged (default), On or Off. Turns the hibernate feature itself on or off (powercfg /hibernate).Unchanged, On, OffUnchanged

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

  1. Run it first with the mode set to Report on one test device. Nothing is changed in that mode.
  2. Read the log and confirm the planned changes are what you expect.
  3. Run your chosen settings on the same test target and confirm the result.
  4. Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
  5. 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

VersionDateChanges
1.0.0November 2026First release.