PowerCLI: How many VMs on your Datastores ?
How many VMs do you have on your datastores ? Do you know ? should you care ?
Yes, you should care, you should care because over saturated datastores can cause issues with IO and also cause scsi locks if you are using fibre. So what is the sweet spot ?
Unfortunately its one of those “It Depends” situations, isn’t everything !
It depends on the type of shared storage you are using, fibre, iSCSI, NFS and also depends on the types of VMs you are using, all I can recommend is that you try and distribute your VMs evenly and try and think about the type of VMs you are putting on the same datastore, for example, if you have multiple SQL servers on the same datastore or if you have an exchange server on the same datastore as your SQL VM’s then do something out it.
The first place I would start is by reading the great Yellow-Bricks article “Max amount of VMs per VMFS volume” where Duncan tells us how he works out his sweet spot
You can see how evenly you are currently distributed with the following one-liner:
Get-Datastore | Select Name, @{N="NumVM";E={@($_ | Get-VM).Count}} | Sort Name
Example Output:
| Name | NumVM |
| ESX01_Local | 0 |
| iscsi_0 | 0 |
| iscsi_1 | 2 |
| iscsi_2 | 1 |
| NFS_1 | 7 |
And don’t forget, with the wonders of Move-VM and SVMotion we can move some VM’s around to start evenly distributing the load on our datastores.
I would also suggest monitoring from the SAN up so you can see straight way if you have a volume or LUN issue.







about 5 months ago
Hi Al,
is this going to make it into V3 of the daily report script ? ( nice to catch up at UKLVMUG yesterday ! )
about 5 months ago
Al, that’s a nice oneliner idea
about 5 months ago
Al,
This is great! I agree with Chris, this would be a perfect addition to the Daily Report (especially if it was set to report based on a custom threshold)
about 3 weeks ago
Al,
I admit I am new to PowerCLI scripting (very new, even), but after running this against my cluster, I see a list of the DataStores, but no heading for “NumVM” and no vm count.
Is it possible I cannot type this one line correctly? Or perhaps this does not work on SAN DataStores?
Thanks very much for the assistance.
about 3 weeks ago
Thats strange, the only thing I can think of is that it is an issue with copying the code from my site, are you using the “copy Source” button that appears when you hover over the code ?
Yes, it definately does work on SAN datastores