The PowerShell scripts which are listed on this page, require VMware vSphere PowerCLI. Before you execute one of these scripts, make sure you’re connected to your Virtual Infrastructure using the following command:

Connect-VIServer -Server "VISERVER"

Get VM count per host

Displays the number of virtual machines per VMware host.

Get-VMHost | Select-Object Name, @{n="VMs";e={($_ | Get-VM).Count}}


Name                                                          VMs
----                                                          ---                                            44                                            43                                            35                                            35                                            35                                            36