VMware Cloud Community
chakoe
Enthusiast
Enthusiast

Script to set some ESX-Host Parameters

Hi,

i need script to set the following ESX-Host-Parameters:

Numa.PageMigEnable = 0

CPU.HaltingIdleMsecPenalty = 5000

I have to do this on more than 100 Host so i would like to use a script....

Is there still a script which i can use?

Thx in advance

Chakoe

0 Kudos
13 Replies
RvdNieuwendijk
Leadership
Leadership

Hi Chakoe,

You can use the Set-VMHostAdvancedConfiguration cmdlet to set the Numa.PageMigEnable and CPU.HaltingIdleMsecPenalty values. Something like this:

Get-VMHost | ForEach-Object {
  Set-VMHostAdvancedConfiguration -VMHost $_ -Name Numa.PageMigEnable -Value 0
  Set-VMHostAdvancedConfiguration -VMHost $_ -Name CPU.HaltingIdleMsecPenalty -Value 5000
}

If you have to set multiple values the next script will be faster:

$NameValues = @{"Numa.PageMigEnable" = 0; "CPU.HaltingIdleMsecPenalty" = 5000}
Get-VMHost | Set-VMHostAdvancedConfiguration -NameValue $NameValues

Although I get an error stating 'CPU.HaltingIdleMsecPenalty' is invalid or exceeds the maximum number of characters permitted. Maybe a typo?

Regards, Robert

Message was edited by: RvdNieuwendijk

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

LINK: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=102023...

Max val is 80,000

Maybe a problem in writing the value ( format oder "" "" )?

0 Kudos
RvdNieuwendijk
Leadership
Leadership

I get the next error running the script from my previous post using PowerCLI 4.1 connected to a vCenter 4.1 Server against an ESX 4.1 or ESXi 4.1 host:

Set-VMHostAdvancedConfiguration : 3-8-2010 15:33:26    Set-VMHostAdvancedConfiguration        'CPU.HaltingIdleMsecPenalty' is invalid or ex
ceeds the maximum number of characters permitted.
At line:3 char:34
+   Set-VMHostAdvancedConfiguration <<<<  -VMHost $_ -Name CPU.HaltingIdleMsecPenalty -Value 5000
    + CategoryInfo          : NotSpecified: (:) [Set-VMHostAdvancedConfiguration], InvalidName
    + FullyQualifiedErrorId : Client20_MoServiceImpl_Invoke_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.SetVMHostAdvancedCon
   figuration

[vSphere PowerCLI] C:\users\robert> $error[0]
Set-VMHostAdvancedConfiguration : 3-8-2010 15:33:26    Set-VMHostAdvancedConfiguration        'CPU.HaltingIdleMsecPenalty' is invalid or ex
ceeds the maximum number of characters permitted.
At line:3 char:34
+   Set-VMHostAdvancedConfiguration <<<<  -VMHost $_ -Name CPU.HaltingIdleMsecPenalty -Value 5000
    + CategoryInfo          : NotSpecified: (:) [Set-VMHostAdvancedConfiguration], InvalidName
    + FullyQualifiedErrorId : Client20_MoServiceImpl_Invoke_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.SetVMHostAdvancedCon
   figuration

[vSphere PowerCLI] C:\users\robert>  $error[0].Exception
3-8-2010 15:33:26    Set-VMHostAdvancedConfiguration        'CPU.HaltingIdleMsecPenalty' is invalid or exceeds the maximum number of charac
ters permitted.
[vSphere PowerCLI] C:\users\robert>  $error[0].Exception.InnerException
'CPU.HaltingIdleMsecPenalty' is invalid or exceeds the maximum number of characters permitted.
[vSphere PowerCLI] C:\users\robert>

Maybe someone from VMware can comment on this?

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

Nothing wrong with the cmdlet as far as I can tell.

Just have to remember that these advanced parameters are case-sensitive.

This works for me

$NameValues = @{"Numa.PageMigEnable" = 0; "Cpu.HaltingIdleMsecPenalty" = 5000}
Get-VMHost | Set-VMHostAdvancedConfiguration -NameValue $NameValues

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

if i run this script against one test-ESX ( 4.0.0 buil 244038) i get the following error:

A spcified parameter was not correct.

The script sets Numa.PageMigEnable correctly, but

<code>"Cpu.HaltingIdleMsecPenalty" = 5000</code> does not work correctly.

Any idea? 

0 Kudos
LucD
Leadership
Leadership

Works for me against ESX 261974.

Can you check if you can set the value from the vSphere client ?

And from the cmdline (see KB1020233.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
RvdNieuwendijk
Leadership
Leadership

Luc's version works for me.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

i can set the value in cmdline.

But i cannot set it in the VSphere Client ( which is Version 4.0.0 build 208111 / vCenter is same )

Greets

Chakoe

0 Kudos
LucD
Leadership
Leadership

I assume you're connected to the vCenter when you ran the script.

Can you try to connect to the ESX server and then run the script ?

Looks like that vCenter build doesn't support the parameter.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
chakoe
Enthusiast
Enthusiast

this might be a newbie-question, but i don´t know how to connect

to a esx directly in PowerCLI Smiley Happy

In the past, i´ve always been connected to the vCenter by using "connect-viserver "

Btw: I tried to connect to the esx directly using the vSphere-Client, but i also can´t see the parameter there...

0 Kudos
LucD
Leadership
Leadership

Same cmdlet, but use the hostname of the ESX server and pass credentials that are defined on the ESX server (for example root and the root password).

Connect-VIServer -Server <esx-hostname> -User <ESX-account> -Password <ESX-password>

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

using the script connected directly to the ESX-Server does not work. Same error.

Script:

$NameValues = @{"Numa.PageMigEnable" = 0; "Cpu.HaltingIdleMsecPenalty" = 5000}

Get-VMHost | Set-VMHostAdvancedConfiguration -NameValue $NameValues

Out:

04.08.2010 10:43:22 Set-VMHostAdvancedConfiguration A specified parameter was not correct.

At :line:2 char:44

+ Get-VMHost | Set-VMHostAdvancedConfiguration &lt;&lt;&lt;&lt; -NameValue $NameValues

Name Value

-


-


Numa.PageMigEnable

0 Kudos
LucD
Leadership
Leadership

Could be that the parameter doesn't work with the ESX build you are using.

I have the impression the parameter only functions since ESX 4u2 (build 261974) but perhaps you better ask in the VMware ESX™ 4 community.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos