This script will connect to a vCenter server and list all hosts it can see and the version of ESXi running on the host. I have also exported this to a csv
Add-PSSnapinVMware.VimAutomation.Core Connect-VIServer-Server vSphereServerName Get-VMHost | Select Name,Version,@{N="vCenter";E={$_.ExtensionData.CLient.ServiceUrl.Split('/')[2]}} |ft name,version | Out-File FileLocationby