Hello,
I am no programmer so feel free to sharply criticize the following code without holding back -):
foreach ($ds in Get-Datastore -Name datastore*) {
$a = 0
foreach ($vm in get-VM -Datastore $ds){
$a++}
Write-Host $ds.Name " VMs: " $a " Capacity: " $ds.CapacityMB " Free: " $ds.FreeSpaceMB
}
All I want to to is iterate through the datstores and find out the number of VMs, the free space and the capacity for each. The later two are actually available by just querying the datastore but I don't think the first is so I wrote what you see above. I have probably 100 datastore of which roughly half follow the naming scheme that would include them in the query. This seemed pretty straigh forward but the query takes over an hour to run
The long running part is the querying of each included datastore for VMs so I can count them. Does the beta perform poorly or is there a better way to get what I am after?
Thanks!