Do you have the credentials for all these ESXi nodes?
I assume they are in $user and $pswd
Get-Content -Path
'C:\temp\lists' -PipelineVariable esxName
|ForEach-Object -Process {
Connect-VIServer -Server $esxName -User $user -Password $pswd
Get-VMHost |
Select Name,
@{N='NumberCPU';E={$_.ExtensionData.Summary.Hardware.numCpuPkgs}},
@{N='CorePerCPU';E={$_.ExtensionData.Summary.Hardware.numCpuCores}},
@{N='CoreTotal';E={$_.ExtensionData.Summary.Hardware.numCpuPkgs*$_.ExtensionData.Summary.Hardware.numCpuCores}}
Disconnect-VIServer -Server $esxName -Confirm:$false
} | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture