Last active
August 29, 2015 14:05
-
-
Save jakerobinson/22711bb993a23aaff863 to your computer and use it in GitHub Desktop.
simple-vm-reporting-in-vcloud-with-powercli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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