PowerShell and Power Options

Systems Administrators love to use feature-rich tools to set up and manage their devices on the network with the desired configuration starting from Group Policy to MS ConfigMgr / System Center Configuration Manager(SCCM). These solutions are robust, complex and but they can be also very expensive to maintain and implement correctly in every scenario.

In this article, we will play with Power Options and with Powershell.

What PowerShell is bringing to the table is, first of all, being included in the OS (for free) and can be used either for simple or complex scenarios depending on your capabilities. This degree of the flexibility to check if everything is working as expected in few lines of code and even to correct issues quickly it depends on the software developer or system engineer that writes the code.

Imagine checking if power option settings are applied correctly to every windows os according to the configuration for the Standard Operating Environment (SOE) image/set-up.

This script will help us to get the power options of a remote host.

This one will set remotely the power options on the target system to High Performance.

In these scripts, WinRM is required an it will be started remotely if the service is not running and then stopped.

Remove this line if you want to leave it running:

There are many cmdlets that accept ComputerName as an argument. For instance, we can perform remote actions without WinRM service running e.g:

  • Get-Process
  • Get-Service
  • Get-EventLog
  • Stop-Computer
  • Restart-Computer
  • etc.

As usual, you can find these scripts on my GitHub repository.

2 Replies to “PowerShell and Power Options”

    1. Hi Hank,
      Thanks for your comment.

      These scripts define a couple of functions, once imported with the dot sourcing and following the instructions they should perform as expected following the examples. I can confirm that these scripts were tested on Win 10, feel free to reach out to me writing a DM attaching your error output.

      Please note that I should have added #requires -runasadministrator as the first line because to apply these changes it’s required to have high privileges on the endpoint.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.