VMware Cloud Community
Dimon_SPB
Contributor
Contributor
Jump to solution

Wrong quantity of VMSockets

Made a simple script:

$VM = get-vm -name ********SQL03

$VMview = get-view $oneVM

$VMCores = $VMview.config.hardware.numcorespersocket

$VMSockets = $VMview.Config.Hardware.NumCPU

$VMCPU = $VM.NumCPU

Write-Host $oneVM.Name -ForegroundColor Cyan

Write-Host "VMCores   - $VMCores" -ForegroundColor Magenta

Write-Host "VMSockets - $VMSockets" -ForegroundColor Magenta

Write-Host "VMCPU     - $VMCPU" -ForegroundColor Magenta

Received strange results.

it turns out to receive VMSockets value through PowerCLI - it is impossible

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

It is possible to do that, but I'm afraid you are interpreting the properties incorrectly.

If you look up the VirtualHardware object in the API Reference, you'll see that it says

numcpu.jpg

The NumCpu property is the total number of vCPU on the VM.
So you have to divide this number by the NumCoresPerSocket to find the number of CPU sockets.

This should provide the correct values

$VM = Get-VM -name MyVM

$VMCoresPerSocket = $VM.ExtensionData.config.hardware.numcorespersocket

$VMSockets = $VM.ExtensionData.Config.Hardware.NumCPU / $VMCoresPerSocket

$VMCPU = $VM.NumCPU


Write-Host $oneVM.Name -ForegroundColor Cyan

Write-Host "VMCores Per Socket - $VMCoresPerSocket" -ForegroundColor Magenta

Write-Host "VMSockets - $VMSockets" -ForegroundColor Magenta

Write-Host "VMCPU - $VMCPU" -ForegroundColor Magenta


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

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

It is possible to do that, but I'm afraid you are interpreting the properties incorrectly.

If you look up the VirtualHardware object in the API Reference, you'll see that it says

numcpu.jpg

The NumCpu property is the total number of vCPU on the VM.
So you have to divide this number by the NumCoresPerSocket to find the number of CPU sockets.

This should provide the correct values

$VM = Get-VM -name MyVM

$VMCoresPerSocket = $VM.ExtensionData.config.hardware.numcorespersocket

$VMSockets = $VM.ExtensionData.Config.Hardware.NumCPU / $VMCoresPerSocket

$VMCPU = $VM.NumCPU


Write-Host $oneVM.Name -ForegroundColor Cyan

Write-Host "VMCores Per Socket - $VMCoresPerSocket" -ForegroundColor Magenta

Write-Host "VMSockets - $VMSockets" -ForegroundColor Magenta

Write-Host "VMCPU - $VMCPU" -ForegroundColor Magenta


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

0 Kudos