You mean something like this?
Note that for Thin harddisk,the capacity property doesn't reflect what the harddisk is actually using on that datastore.
I show a method for that in my Yadr – A Vdisk Reporter post.
Get-View -ViewType VirtualMachine -PipelineVariable vm |
ForEach-Object -Process {
$vm.Config.Hardware.Device | where{$_ -is [VMware.Vim.VirtualDisk]} |
ForEach-Object -Process {
New-Object PSObject -Property @{
VM = $vm.Name
HD = $_.DeviceInfo.Label
Datastore = (Get-View -Id $_.Backing.Datastore -Property Name).Name
CapacityGB = [math]::Round($_.CapacityInBytes/1GB,1)
}
}
}