PowerShell Power for Presenters

As a presenter I frequently need to make sure that my laptop is not in low power battery saving mode. I also don’t want the screensaver to start up when I walk away from the computer and point at the screen. A while back, I showed you how to Control Power with PowerShell, but this time we’re going to go one step further - we’re going to build a presentation mode.

Set-PresentationModeOn

My only goal for this was to have a quick way to put a laptop into high performance mode and then switch back to a balanced power plan when I’m done with a presentation. Initially I used the Set-PowerHighPerformance function that I shared with you previously. Unfortunately, when I was away flailing around in front of the screen for a while, the screen suddenly when blank when I my screensaver turn on. Eager to solve the problem, I reserached how to disable both monitor sleep and the screensaver. We can accomplish this using some powercfg options (specifically -change,-standby-timeout-ac and -monitor-timeout-ac) and changing a registry value. To make this happen, there are four functions Set-ScreenSaverTimeout, Set-DisplaySleep,Set-PresentationModeOff, and Set-PresentationModeOn. The only two I use are Set-PresentationModeOnand Set-PresentationModeOff

PowerPlan - A PowerShell Module for Presenters

After rolling several individual functions, I put together a PowerShell module that I’m calling PowerPlan. PowerPlan wraps up all of the code from Control Power with PowerShell as well as the new functions I’ve described above.

Installing and Using the PowerPlan Module

  • Change to your PowerShell modules directory. By default this isC:\Users\YOUR_NAME_HERE\Documents\WindowsPowerShell\Modules.
  • Get a copy of the PowerPlan module.
    • Clone it git clone [email protected]:peschkaj/PowerPlan.git
    • Download the ZIP. If you download the ZIP, you’ll need to rename the folder fromPowerPlan-master to PowerPlan.
  • Add this to your PowerShell profile: Import-Module PowerPlan

The Gotcha

There’s one gotcha - if your screensaver settings are pushed down to your computer through group policy the registry changes on line 44 will fail. The first GitHub Issue is for me to detect the right registry entry and not fail but, right now, it’s gonna fail.

Feedback

If you want to share feedback - create a new GitHub issue. We’ll chat. It’ll be fun.