VMware Cloud Community
thb_
Enthusiast
Enthusiast
Jump to solution

How to determine/set Power Management setting

Is there a way to determine and set the Power Management Setting / Power Policy setting from esx Host's through PowerCLI?

Tags (2)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Something like this

$desiredPowerPolicy = "static"        # Options are: static,dynamic,low,custom  

Get-VMHost | %{     $powSys = Get-View $_.ExtensionData.ConfigManager.PowerSystem     $key = ($powSys.Capability.AvailablePolicy | where {$_.ShortName -eq $desiredPowerPolicy}).Key    
    $powSys
.ConfigurePowerPolicy($key) }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
14 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The setting is per cluster, not per host. You can determine the setting with:

Get-Cluster | Sort-Object -Property Name | Select-Object Name,
@{N="DpmEnabled";E={$_.ExtensionData.ConfigurationEx.DpmConfigInfo.Enabled}},
@{N="DefaultDpmBehavior";E={$_.ExtensionData.ConfigurationEx.DpmConfigInfo.DefaultDpmBehavior}},
@{N="HostPowerActionRate";E={$_.ExtensionData.ConfigurationEx.DpmConfigInfo.HostPowerActionRate}}

To figure out how to set it, takes some more time.

I think I misunderstood your question at first. The first script shows the Distributed Power Management setting per cluster. The next script shows the current power policy for all your hosts:

Get-VMHost | Sort-Object -Property Name | Select-Object -Property Name,
@{N="CurrentPowerPolicy";E={$_.ExtensionData.Config.PowerSystemInfo.CurrentPolicy.ShortName}}

or to make the script faster:

Get-View -ViewType Hostsystem -Property Name,Config.PowerSystemInfo.CurrentPolicy.ShortName | `
Sort-Object -Property Name | Select-Object -Property Name,
@{N="CurrentPowerPolicy";E={$_.Config.PowerSystemInfo.CurrentPolicy.ShortName}}

Regards, Robert

Message was edited by: RvdNieuwendijk Added the second and third script.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
LucD
Leadership
Leadership
Jump to solution

I'm afraid that the prevous statement is not correct, you can set DPM settings per host in a cluster.

This will show the cluster and the host DPM settings (when they are present).

Get-Cluster | %{
    $_ | Select @{N="Cluster";E={$_.Name}},
        @{N="DpmEnabled";E={$_.ExtensionData.ConfigurationEx.DpmConfigInfo.Enabled}},
        @{N="DefaultDpmBehavior";E={$_.ExtensionData.ConfigurationEx.DpmConfigInfo.DefaultDpmBehavior}},
        @{N="HostPowerActionRate";E={$_.ExtensionData.ConfigurationEx.DpmConfigInfo.HostPowerActionRate}} | Out-Default        if($_.ExtensionData.ConfigurationEx.DpmHostConfig){
            $_.ExtensionData.ConfigurationEx.DpmHostConfig | 
            Select @{N="Host";E={(Get-View $_.Key).Name}},
                    @{N="DpmHostEnabled";E={$_.Enabled}},
                    @{N="DpmHostBehavior";E={$_.Behavior}}
        }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
thb_
Enthusiast
Enthusiast
Jump to solution

thanks for your help.

Sorry for the misunderstanding. I was not looking for DPM settings.

The power policy was the info i was looking for. And it works great so far to get the info.

It' would still be interesting how to set the power policy per host through powercli.

Regards

Thomas

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Something like this

$desiredPowerPolicy = "static"        # Options are: static,dynamic,low,custom  

Get-VMHost | %{     $powSys = Get-View $_.ExtensionData.ConfigManager.PowerSystem     $key = ($powSys.Capability.AvailablePolicy | where {$_.ShortName -eq $desiredPowerPolicy}).Key    
    $powSys
.ConfigurePowerPolicy($key) }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Beansley
Contributor
Contributor
Jump to solution

Are there extensions showing the  IPMI/iLO Settings per host?  We've found that upgrading to vSphere 5 does not preserve those settings, so I'd like to script pulling out those parameters and export to csv vs. logging in to each blade's iLO again to find IP and MAC address.

Thanks

Dave

Reply
0 Kudos
qwert1235
Enthusiast
Enthusiast
Jump to solution

Luc,

Is there a way just list  CPU Power Management setting for each host?

Thanks,

qwert

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sure, use something like this

Get-VMHost  | 
Select Name,@{N="Power Policy";E={
    $powSys = Get-View $_.ExtensionData.ConfigManager.PowerSystem
    $powSys.Info.CurrentPolicy.ShortName
  }}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

qwert1235
Enthusiast
Enthusiast
Jump to solution

Luc,

Thanks a lot!   It's working great!!!!!

Reply
0 Kudos
qwert1235
Enthusiast
Enthusiast
Jump to solution

Luc,

This script works great for ESX hosts 4.1 and higher, but not for 4.0

On 4.0 "Power Management Policy" (when you checking it through VI client) located under "Processors" and there is no "Power Management" tab at all.

How can I find out "Power Management Policy" on ESXi hosts 4.0? (I think I have to use ConfigManager.CpuScheduler, but not sure)

Thanks a lot!

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm afraid not, afaik the HostPowerSystem was introduced in vSphere 4.1.

See the remark under Since in the SDK Reference for that object.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
qwert1235
Enthusiast
Enthusiast
Jump to solution

Luc,

Thank you very much for the info!

Reply
0 Kudos
Pinball
Enthusiast
Enthusiast
Jump to solution

Hi Luc

How will i go about updating all hosts in VC to use "static" instead of the script below that does it on a named base.

$view = (Get-VMHost esxi.domain.local   | Get-View)

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


Thanks



Johan

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try something like

Get-VMHost | %{

     (Get-View $_.ExtensionData.ConfigManager.PowerSystem).ConfigurePowerPolicy(1)

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
moellerjot
Enthusiast
Enthusiast
Jump to solution

my Quickfix: 😁

Param(
  [Parameter(Mandatory=$True,Position=1)]
   [string]$VMHostName,
   [string]$SetToValue
   )
if($VMHostName) {
      $vcHosts=Get-VMHost $VMHostName
} else {
      $vcHosts=Get-VMHost|sort
}

$vcHosts|foreach {
   $Myhosti = ($_| Get-View)
      $MyPowerPolicy = (get-view ($Myhosti.ConfigManager.PowerSystem)).Info.CurrentPolicy
      $MyPowerPolicy.ShortName


      if ($SetToValue -ne "") {
            write-host $Myhosti.Name PowerPolicy current= $MyPowerPolicy.ShortName value= $MyPowerPolicy.Key will be set to Value= $SetToValue
            (Get-View $Myhosti.ConfigManager.PowerSystem).ConfigurePowerPolicy($SetToValue)
      }
      elseif($SetToValue -eq "") {
            write-host $Myhosti.Name PowerPolicy current= $MyPowerPolicy.ShortName Value= $MyPowerPolicy.Key
      }
}
Reply
0 Kudos