DevelopmentInformation TechnologyVirtualization

Count Running Virtual Machines on Datastores

Found another good candidate for a PowerVI script

If you are running too many VM´s on your datastores in your vSphere environment you can have some problems, this if your SAN is not VAAI compliant and can handle SCSI locking etc.

Alan Renouf has made a blog post about how to get a report about how many VM´s you have on every datastore, I have extended to only report on running VM´s as these are the interesting number..

(read more)

I would alter his script slightly for use in PowerVI.

#--name Virtual Machines Per Datastore
#--multi --hideoutput
#--origin PowerSE

Get-Datastore | 
	Select Name,@{Name="TotalVMs";Expression={@($_ | 
	@{Name="PoweredOnVMs";Expression={@($_ | Get-VM | where {$_.PowerState -eq "PoweredOn"}).Count}}, 
	@{Name="PoweredOffVMs";Expression={@($_ | Get-VM | where {$_.PowerState -eq "PoweredOff"}).Count}}, 
	@{Name="SuspendedVMs";Expression={@($_ | Get-VM | where {$_.PowerState -eq "Suspended"}).Count}} | 
	Sort Name |