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
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.
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
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
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
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
Luc,
Is there a way just list CPU Power Management setting for each host?
Thanks,
qwert
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
Luc,
Thanks a lot! It's working great!!!!!
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!
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
Luc,
Thank you very much for the info!
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
Try something like
Get-VMHost | %{
(Get-View $_.ExtensionData.ConfigManager.PowerSystem).ConfigurePowerPolicy(1)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
}
}