Because of the unique requirement of VMs to exist inside vApps in vCloud Director, it’s a challenge to get a nice view of all the VMs and their locations within your vCloud Organization. This can mostly be satisfied with a Get-CIVM command, which will return great info about your VMs, but it’s missing the storage assignment. Here’s a sweet little script to report specifically on the VM resources in use inside your vCloud Organization:
$vms = get-civm
$objects = @()
foreach($vm in $vms)
{
$hardware = $vm.ExtensionData.GetVirtualHardwareSection()
$diskMB = (($hardware.Item | where {$_.resourcetype.value -eq "17"}) | %{$_.hostresource[0].anyattr[0]."#text"} | Measure-Object -Sum).sum
$row = New-Object PSObject -Property @{"vapp" = $vm.vapp; "name"=$vm.Name;"cpuCount"=$vm.CpuCount;"memoryGB"=$vm.MemoryGB;"storageGB"=($diskMB/1024)}
$objects += $row
}
# Use select object to get the column order right. Sort by vApp. Force table formatting and auto-width.
$objects | select-Object name,vapp,cpuCount,memoryGB,storageGB | Sort-Object -Property vapp | Format-Table -AutoSize
You can easily export to a CSV by using Export-CSV or just run the report to get output that looks something like this:









