Sorry I explained wrong, what I intend to do is to make an estimate based on the cores that have the processors and the cores consumed , based on that estimate whose VMs are configured Core per Socket 1:4.
I have created this script but I can't find the error, could you please help me?
param(
[Parameter(Mandatory = $false)]
[String]$cluster,
$vmhosts="*"
)
$vmhosts=get-cluster $cluster | Get-VMHost $vmhosts
$vms=Get-VM
$Output=@()
ForEach ($vmhost in $vmhosts)
{
$vcpus=0
$ratio=$null
$hostthreads=$vmhost.extensiondata.hardware.cpuinfo.NumCpuCores
$vms |Where-Object {$_.vmhost -like $vmhost}|ForEach {$vcpus+=$_.numcpu}
if ($vcpus -ne "0") {$ratio= "$("{0:N2}" -f ($vcpus/$hostthreads))" + ":1"}
$temp= New-Object psobject
$temp| Add-Member -MemberType Noteproperty "Hostname" -value $vmhost.name
$temp| Add-Member -MemberType Noteproperty "Cluster" -value $vmhost.parent.name
$temp| Add-Member -MemberType Noteproperty "PhysicalThreads" -Value $Hostthreads
$temp| Add-Member -MemberType Noteproperty "vCPUs" -Value $vcpus
$temp| Add-Member -MemberType Noteproperty "Ratio" -Value $ratio
$Output+=$temp
}
$output