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.
https://communities.vmware.com/thread/461039
 

12 comments:

  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

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

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

    ReplyDelete
  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

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

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

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

    ReplyDelete
  8. 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

    ReplyDelete
  9. Expanding you business through the internet is something that many traditional business owners would like to do. In fact, online business itself is already a very lucrative industry. For any sort of business to operate on the internet, they will require a website. The website is the only way that they can allow themselves to be visible to millions of internet users out there. The internet provides a lot of possibilities as well as solutions but for a website to succeed, it will require a web hosting service. There are many type of hosting service available out there today and should you rick your business with a cheap hosting? https://hostinglelo.in/

    ReplyDelete
  10. buy youtube views Action games are more prominent than other games. Compared to adventure games they are more interactive and provide a greater adrenalin rush. They basically belong to that variety which includes striking games like fighting, star wars, space travels, wrestling, situational games and many more and we, at xpert4u.co.uk provide you with all these and many more.

    ReplyDelete
  11. Cheapest player speeches and toasts, or maybe toasts. continue to be brought about real estate . during evening reception tend to be likely to just be comic, witty and therefore instructive as well. best man speeches free Crypto Arbitrage

    ReplyDelete
  12. A big thank you for your blog article. Thanks Again. Will read on...
    saip wire

    ReplyDelete