Inspired by Jason Boche’s article: http://www.boche.net/blog/index.php/2009/08/18/hidden-virtual-cpu-limit-restriction-in-esx-3-5/ and also William Lam’s Perl Script (http://communities.vmware.com/docs/DOC-10556).  I decided to re-create this in PowerCLI.

If you haven’t seen William’s scripts, I strongly suggest you check out the Perl Sample code where he stores them here: http://communities.vmware.com/community/developer/codecentral/vsphere_perl, he has been coding mad recently and turning out some really good stuff.

The PowerCLI script gives the following output:

Cluster: Production
Host: vmgesx01.vmguru.com
Misc.RunningVCpuLimit: 128
Number of vCPU on host: 4
Host: vmgesx02.vmguru.com
Misc.RunningVCpuLimit: 128
Number of vCPU on host: 3
Host: vmgesx03.vmguru.com
Misc.RunningVCpuLimit: 128
Number of vCPU on host: 2
Host: vmgesx04.vmguru.com
Misc.RunningVCpuLimit: 128
Number of vCPU on host: 5
———-
Number of vCPU in Production: 14
———-

And the code is below:

Connect-VIServer testviserver

$TotalNumvCPUs = 0
Foreach ($Cluster in (Get-Cluster |Sort Name)){
$HostNumvCPUs = 0
Write-Host Cluster: $($Cluster.name)
Foreach ($ESXHost in ($Cluster |Get-VMHost |Sort Name)){
Write-Host Host: $($ESXHost.name)
$RunningLimit = $null
$RunningLimit = ($ESXHost |Get-VMHostAdvancedConfiguration).get_Item(Misc.RunningVCpuLimit)
If ($RunningLimit -eq $null){
$RunningLimit = 128
}
Write-Host Misc.RunningVCpuLimit: $RunningLimit
Foreach ($VM in ($ESXHost |Get-VM)){
$HostNumvCPUs += ($VM).NumCpu
}
Write-Host Number of vCPU on host: $($HostNumvCPUs)
$TotalNumvCPUs += $HostNumvCPUs
$HostNumvCPUs = 0
}
Write-Host ———-
Write-Host Number of vCPU in $($Cluster.name): $TotalNumvCPUs
Write-Host ———-
Write-Host “”
$TotalNumvCPUs = 0
}