none
Set the power profile to "High Performance" with powershell on multiple computers RRS feed

  • Question

  • I want to set the power profile to "High Performance" and prevent standby on roughly 150 computers using a powershell script.  I am a powershell novice so any help would be greatly appreciated.

    Thank in advance for any help or suggestions.

    Saturday, August 22, 2015 10:05 AM

Answers

  • After multiple tries, this is what ended up working for me.  Seems I just needed more time to figure it out.

    $comp = get-content computers.txt
    $cred = Get-Credential domain\user
    $s = new-pssession -computername $comp
    invoke-command -session $s { powercfg.exe -SETACTIVE 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c }

    I think maybe I was trying to make it harder than it was!

    Thanks!

    Saturday, August 22, 2015 1:08 PM

All replies

  • What is "high performance"?  Are you asking about laptop power profiles?  Desktops are set to that by default.

    To manage power profiles we would use "powercfg"  start with: "powercfg /?"

    There is no native PowerShell command for this.


    \_(ツ)_/


    • Edited by jrv Saturday, August 22, 2015 11:11 AM
    Saturday, August 22, 2015 11:08 AM
  • Desktops.  Our desktops have a "balanced" power profile set by default and it forces them to sleep after 30 minutes. I know there is no native PowerShell command to do this.  I am looking for a way to script to set the power profile on all of them to the high performance profile and disable the sleep.

    Something like the following, which I can do by remoting in through PSSession on a single machine and it works, but I am not sure how to do it on multiple machines at once to automate it.


    Get-WmiObject -Class Win32_PowerPlan -Namespace root\cimv2\power -Filter "ElementName= 'High Performance'" | Invoke-WmiMethod -Name Activate
    powercfg.exe -SETACTIVE 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
    $exe = "C:\Windows\system32\powercfg.exe"
    $arguments = "-x -standby-timeout-ac 0"
    $proc = [Diagnostics.Process]::Start($exe, $arguments)
    $proc.WaitForExit()


    • Edited by Kubiaka Saturday, August 22, 2015 11:29 AM
    Saturday, August 22, 2015 11:28 AM
  • You can set the power profile with Group Policy.

    https://technet.microsoft.com/en-us/library/Dd759141.aspx?f=255&MSPPError=-2147217396


    \_(ツ)_/

    Saturday, August 22, 2015 11:31 AM
  • I am aware of that, thank you, but that is not what I am looking for.
    Saturday, August 22, 2015 11:38 AM
  • What you are looking for does not exist. Power Options are only available with POWERCFG.

    \_(ツ)_/

    Saturday, August 22, 2015 11:40 AM
  • In what sense?  Like I said, I have done it by using PSSession on a single machine and was able to do it with PowerShell and it works just fine, using POWERCFG as I showed you in the post above with the script snippet. Why would I not be able to do it on a group of machines?
    Saturday, August 22, 2015 11:44 AM
  • If you want to try and learn PowerShell and WMI you can use WMI to set the profile but it is not easy when ther are many computers to set and keep set.  That is why we use a GPO.

    See: http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/27/use-powershell-and-wmi-or-cim-to-view-and-to-set-power-plans.aspx


    \_(ツ)_/

    Saturday, August 22, 2015 11:45 AM
  • In what sense?  Like I said, I have done it by using PSSession on a single machine and was able to do it with PowerShell and it works just fine, using POWERCFG as I showed you in the post above with the script snippet. Why would I not be able to do it on a group of machines?

    Since you know that then what is your question?  You seem to have the answer and are still asking the same question.


    \_(ツ)_/

    Saturday, August 22, 2015 11:47 AM
  • I understand where you are coming from, but I am in a satellite office of a large corporation where our GP is set by someone on the other side of the world and getting it added to GP is 50 miles of red tape and a year to get it done.  As it stands right now there is no GP set for the power profile. I am the local admin for this office but I do not have rights to change or update the GP. I do have Admin rights to all the machines though. So you see this is a little bit of a pain and why I am looking for a way to solve it. Yes, I do know how to do it on one machine at a time, but I haven't been able to figure out a way to do all of them at once. Are you saying I am going to have to do all of them individually?
    • Proposed as answer by k, Santosh Monday, October 21, 2019 2:04 PM
    • Unproposed as answer by k, Santosh Monday, October 21, 2019 2:04 PM
    Saturday, August 22, 2015 11:53 AM
  • just loop through all of the machines and set the profile.  Chances are the Domain Admins have already set the power profile to "saver" or "balanced" and your script will just be over-written.  Try it.  If it works you are set.


    \_(ツ)_/

    Saturday, August 22, 2015 12:00 PM
  • I know for a fact there is no GP set for the power profile so that is not an issue. These machines are all loaded with a modified Win7 image that has the power profile set to balanced. I guess I will just do it for each machine individually or search for help somewhere else where someone can maybe help me figure out how to do it on multiple machines.

    Thanks

    Saturday, August 22, 2015 12:08 PM
  • I gave you the answer above.  Just lop through all of the machines and set the profile.  Why I that a problem?


    \_(ツ)_/

    Saturday, August 22, 2015 12:11 PM
  • Here is an example:

    Get-AdComputer -filter *  | %{ Invoke-Command -computer $_.Name -scriptblock $powerscript }

    help invoke-command
    help Get-AdCOmputer


    \_(ツ)_/

    Saturday, August 22, 2015 12:14 PM
  • Like I said, not very good at PowerShell, and the script fails to set it when I do it on multiple machines, but works fine if I do it by entering into a remote session and run it.

    Here is the script I used:

    $computername = Get-Content "C:\computers.txt"
    foreach ($computer in $computername)
    {Get-WmiObject -Class Win32_PowerPlan -Namespace root\cimv2\power -Filter "ElementName= 'High Performance'" | Invoke-WmiMethod -Name Activate
    powercfg.exe -SETACTIVE 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
    $exe = "C:\Windows\system32\powercfg.exe"
    $arguments = "-x -standby-timeout-ac 0"
    $proc = [Diagnostics.Process]::Start($exe, $arguments)
    $proc.WaitForExit()}


    Saturday, August 22, 2015 12:18 PM
  • After multiple tries, this is what ended up working for me.  Seems I just needed more time to figure it out.

    $comp = get-content computers.txt
    $cred = Get-Credential domain\user
    $s = new-pssession -computername $comp
    invoke-command -session $s { powercfg.exe -SETACTIVE 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c }

    I think maybe I was trying to make it harder than it was!

    Thanks!

    Saturday, August 22, 2015 1:08 PM
  • I have used the below command during OSD with a run command line and it worked for me, I hope this would help you.

    PowerCfg.exe /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c

    Monday, October 21, 2019 2:06 PM