VMware Cloud Community
ekrejci
Enthusiast
Enthusiast
Jump to solution

how to modify vSphere power policy with powercli

Hi,

I'm looking a way to modify the power management settings for the hosts with powercli.

switching between the 4 policy and getting info on hosts having this capability.

I didn't find anything so far

any clue?

thanks

Eric

1 Solution

Accepted Solutions
MKguy
Virtuoso
Virtuoso
Jump to solution

To get info on the current settings of your hosts:

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}}

Name                                               CurrentPolicy                                                                 CurrentPolicyKey   AvailablePolicies

----                                                           -------------                                                                 ----------------                     -----------------

esxihost0021.domain.local                        static                                                                                       1  {static, dynamic, low, custom}

esxihost0022.domain.local                        static                                                                                       1  {static, dynamic, low, custom}

esxihost0033.domain.local                        off                                                                                            0  static

esxihost0034.domain.local                        off                                                                                            0  static

esxihost0041.domain.local                        static                                                                                       1  static

esxihost0062.domain.local                        dynamic                                                                                  2  {static, dynamic, low, custom}

esxihost0063.domain.local                        dynamic                                                                                  2  {static, dynamic, low, custom}

Note: CurrentPolicy off indicates that the host does not support OS-controlled power management or you set the host BIOS to a specific power management policy like static high performance already.

To set the power policy for a host:

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

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

Where X equals the key of the policy you want to set (1=static, 2=dynamic, 3=low, 4=custom)

-- http://alpacapowered.wordpress.com

View solution in original post

7 Replies
MKguy
Virtuoso
Virtuoso
Jump to solution

To get info on the current settings of your hosts:

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}}

Name                                               CurrentPolicy                                                                 CurrentPolicyKey   AvailablePolicies

----                                                           -------------                                                                 ----------------                     -----------------

esxihost0021.domain.local                        static                                                                                       1  {static, dynamic, low, custom}

esxihost0022.domain.local                        static                                                                                       1  {static, dynamic, low, custom}

esxihost0033.domain.local                        off                                                                                            0  static

esxihost0034.domain.local                        off                                                                                            0  static

esxihost0041.domain.local                        static                                                                                       1  static

esxihost0062.domain.local                        dynamic                                                                                  2  {static, dynamic, low, custom}

esxihost0063.domain.local                        dynamic                                                                                  2  {static, dynamic, low, custom}

Note: CurrentPolicy off indicates that the host does not support OS-controlled power management or you set the host BIOS to a specific power management policy like static high performance already.

To set the power policy for a host:

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

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

Where X equals the key of the policy you want to set (1=static, 2=dynamic, 3=low, 4=custom)

-- http://alpacapowered.wordpress.com
ekrejci
Enthusiast
Enthusiast
Jump to solution

excellent.

works like a charme.

thank you very much

Eric

Reply
0 Kudos
RebeccaG
Expert
Expert
Jump to solution

Very nice answer, thank you!

Reply
0 Kudos
PhillipUdel
Contributor
Contributor
Jump to solution

I guess I missed something.   I see how to set to static,  but how do I set to High Performance?

Reply
0 Kudos
MKguy
Virtuoso
Virtuoso
Jump to solution

"static" is the alias name for the "Static High Performance" power management policy.

-- http://alpacapowered.wordpress.com
gajuambi
Enthusiast
Enthusiast
Jump to solution

Here is an onelier to get this done on all hosts of your vcenter

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

Where

1=HighPerformance

2=Balanced

3=LowPower

---------------------- Gajendra D Ambi [pardon my chat lingo]
Kirhner
Contributor
Contributor
Jump to solution

Thanks man. Works excellent.

I like simple code in one line.....

Reply
0 Kudos