PowerCLI - Configure multiple ESXi Power Policy

1 minute read 0 Comments

This is a quick powershell script that setups up ESXi Power Policies in all the hosts in a cluster or vCenter.

Script Parameters

  • Mandatory
    • vCenter » vCenter FQDN/IP to connect too
    • vCenterUsername » vCenter Username
    • vCenterPassword » corresponding password
    • powerProfile » Power Profile config to use:
      • High Performance
      • Balanced
      • Low Power
      • Custom
  • Optional
    • cluster » Cluster name if we want to change the hosts from a single cluster

The code is pretty simple, but it worth to point out the relevant parts of it

  • Hash Table to adapt/translate the common name of the Power Policies to the right value needed by the ConfigurePowerPolicy method
# Keys for the values needed for the ConfigurePowerPolicy method
$powerProfiles =  @{
    "High Performance" = 1 ;
    "Balanced"         = 2 ;
    "Low Power"        = 3 ;
    "Custom"           = 4
  • List the current status
$currentState = $vmHosts | Sort-Object $_.Name| `
 Select Name,@{ N="CurrentPolicy"; `
    E={$_.ExtensionData.config.PowerSystemInfo.CurrentPolicy.ShortName}}, `
    @{ N="CurrentPolicyKey"; `
      E={$_.ExtensionData.config.PowerSystemInfo.CurrentPolicy.Key}}, `
    @{ N="AvailablePolicies"; `

 $currentState | Format-Table -AutoSize
  • Change effectively the Power Policy
# Set the PowerProfile to the desired state
(Get-View ($vmHosts | `

Leave a comment

Your email address is used to display your Gravatar, if applicable, and subscribe you to replies using the Mailgun web service, which you are free to unsubscribe from when you get any emails. Your email address will not be displayed publicly or shared with anyone else.