profile for Gajendra D Ambi on Stack Exchange, a network of free, community-driven Q&A sites

Tuesday, September 8, 2015

Automating ESXi host power management policies via powercli

If you have many ESXi hosts and you wanted to get all the juice out of your ESXi (well you paid heavily for it didn't you, so you better get all you can out of it) then you might have thought of changing the power management policy on your esxi hosts. I am not talking about the DPM but the host>configuration>hardware>power management settings.
I want to set it to high performance but you might want to set it to balanced but for the sake of this post let it be high performance which is 1.
First you wanna get the already set value for your 10s or 100s of hosts. you do that with  the following

Get-VMHost | Sort | Select Name,@{ N="CurrentPolicy"; E={$_.ExtensionData.config.PowerSystemInfo.CurrentPolicy.ShortName}},@{ N="CurrentPolicyKey"; E={$_.ExtensionData.config.PowerSystemInfo.CurrentPolicy.Key}},@{ N="AvailablePolicies"; E={$_.ExtensionData.config.PowerSystemCapability.AvailablePolicy.ShortName}}

If you want to set it then you might want to do it like this

$view = (Get-VMHost $VMHost   | Get-View)
(Get-View $view.ConfigManager.PowerSystem).ConfigurePowerPolicy(1)

replace the $VMHost with your hostname
 Please note that the above value is set to 1 which means performance. The other values are

1=HighPerformance /2=Balanced /3=LowPower

Now you might want to shorten it like this
{(Get-View (Get-VMHost $VMHost | Get-View).ConfigManager.PowerSystem).ConfigurePowerPolicy(1)}

What if you want to do the same for many hosts, well powershell looping got you covered.

foreach ($VMHost in (Get-VMHost)){(Get-View (Get-VMHost $VMHost | Get-View).ConfigManager.PowerSystem).ConfigurePowerPolicy(1)} 

and if you are feeling even lazier than I am then here is a shortest oneliner that I could think of for this

(Get-View (Get-VMHost | Get-View).ConfigManager.PowerSystem).ConfigurePowerPolicy(1)

So that's it folks, for more info check out the vmware communities link for the same.


  1. Thanks for your time so much for your impressive and amazing guide. I will not be reluctant to endorse your web sites to any individual who should receive direction on this problem. web design

  2. Immigration… [...]the time to read or visit the content or sites we have linked to below the[...]… web designer

  3. Hey there! Wonderful stuff, please do tell us when you post again something similar! web design

  4. Immediately a bit of guests will continue across hotel rooms and obtain tied bus excursions, however, many with all the fancy car applications provide your own tour specialist. That just might help you browse through the neighborhood well you could an individual’s chose chauffeur. ??? ???? ipad template

  5. This is something I actually have to try and do a lot of analysis into, thanks for the post apple desktop mockup

  6. The subsequent time I read a blog, I hope that it doesnt disappoint me as a lot as this one. I imply, I do know it was my choice to learn, however I actually thought youd have something attention-grabbing to say. All I hear is a bunch of whining about something that you could repair in the event you werent too busy in search of attention. mobile mockup

  7. Yeah bookmaking this wasn’t a bad decision great post! . webflow agency

  8. Great post, I’m looking forward to hear more from you!! web development companies

  9. providing configurable strategy layouts, and making policies revelatory instead of procedural, consequently empowering dynamic organizations to be handily changed as the conditions interest. F and I resources in Missouri & Kansas