I have a need to turn off hyperthreading on potentially a few hundred hosts and cannot figure out how to take the script from this thread https://communities.vmware.com/thread/326949?q=disable%20Hype and modify it to hit multiple hosts or ever a cluster.
## host upon which to act
$strMyHostName = "myhost.domain.com"
## get the View object for the HostCpuSchedulerSystem
$viewHostCPUSchedulerSystem = Get-View (Get-View -ViewType HostSystem -Property ConfigManager.CpuScheduler -Filter @{"Name" = $strMyHostName}).ConfigManager.CpuScheduler
## disable hyperthreading
$viewHostCPUSchedulerSystem.DisableHyperThreading()
Can anyone comment on how to do that? It can use an answer file or hostname with wildcard or even hit a cluster rather than host but I need to hit more than one at a time with this change. Any help is greatly appreciated!
You can do this for all ESXi nodes in a ForEach loop, like this
Get-VMHost | %{
$viewHostCPUSchedulerSystem = Get-View $_.ExtensionData.ConfigManager.CpuScheduler
$viewHostCPUSchedulerSystem.DisableHyperThreading()
}
If you want to limit the ESXi nodes, you can adapt the first line.
For all ESXi nodes in a cluster
Get-Cluster -Name MyCluster | Get-VMHost | %{
$viewHostCPUSchedulerSystem = Get-View $_.ExtensionData.ConfigManager.CpuScheduler
$viewHostCPUSchedulerSystem.DisableHyperThreading()
}
or for all ESXi nodes whose name starts with My
Get-VMHost -Name My* | %{
$viewHostCPUSchedulerSystem = Get-View $_.ExtensionData.ConfigManager.CpuScheduler
$viewHostCPUSchedulerSystem.DisableHyperThreading()
}
... and so on.
Is there a specific selection of ESXi nodes you had in mind?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can do this for all ESXi nodes in a ForEach loop, like this
Get-VMHost | %{
$viewHostCPUSchedulerSystem = Get-View $_.ExtensionData.ConfigManager.CpuScheduler
$viewHostCPUSchedulerSystem.DisableHyperThreading()
}
If you want to limit the ESXi nodes, you can adapt the first line.
For all ESXi nodes in a cluster
Get-Cluster -Name MyCluster | Get-VMHost | %{
$viewHostCPUSchedulerSystem = Get-View $_.ExtensionData.ConfigManager.CpuScheduler
$viewHostCPUSchedulerSystem.DisableHyperThreading()
}
or for all ESXi nodes whose name starts with My
Get-VMHost -Name My* | %{
$viewHostCPUSchedulerSystem = Get-View $_.ExtensionData.ConfigManager.CpuScheduler
$viewHostCPUSchedulerSystem.DisableHyperThreading()
}
... and so on.
Is there a specific selection of ESXi nodes you had in mind?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks @LucD! I was all over that solution but could not get the syntax correct. You're a lifesaver!
