Hi. Thanks to LucD I am progressing with my script to get vCenter details but the one bit I am stuck on is with regard to the datastore disk usage particularly if a VM has more than one VMDK and they are on separate datastores.
At the moment, I am using the code below to get the datastore names:
(Get-View -Id $vm.Datastore -Property Name).Name -join “|”
and the code below to get the VM diskspace usage:
[math]::Round(($vm.Storage.PerDatastoreUsage.Committed | Measure-Object -Sum).Sum/1GB,1)
What I would like to do is get the disk size for each VMDK. For example if a VM has 2 x VMDKs on separate datastores, I would like the report to show:
datastore1 50Gb
datastore2 30Gb
Any ideas please?