If you want to boost the performance of the script you can avoid calling Get-VM like this (slightly modifying the script of LucD):
Get-VMHost | Sort-Object Name | Select Name,@{N="VM";E={ if ($_.ExtensionData.Vm -ne $null) { $_.ExtensionData.Vm.Count } else {0}}}
-
PowerCLI development team