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