Skip to content

Instantly share code, notes, and snippets.

@jakerobinson
Last active August 29, 2015 14:05
Show Gist options
  • Save jakerobinson/22711bb993a23aaff863 to your computer and use it in GitHub Desktop.
Save jakerobinson/22711bb993a23aaff863 to your computer and use it in GitHub Desktop.
simple-vm-reporting-in-vcloud-with-powercli
$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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment