VMware Cloud Community
Gaprofitt17
Enthusiast
Enthusiast

vCloud Director help with powerCLI pulling data

I'm trying to pull the following and not having much success:

Org Name, VDC name, associated vAPPS and underlying VM's.  I also need created date.

I've tried various scripts and not having much success..

 

For example:

 

$ListOrg = Get-Org | Sort-Object -Property Name
# Write the list and prompt for input
write-host "$ListOrg"
write-host ""
$Org = read-host "Please Enter the Name of the Org"
$vms = Get-Org -Name $Org | get-civm
$objects = @()
 
# Jakes Smarts
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
 
# Also Export results to CVS for further processing
$objects | Export-Csv "$Org.csv" -NoTypeInformation -UseCulture


II don't really want them listed individually, but as groups..  Any easy tool or way of going this?
0 Kudos
1 Reply
Macleud
Enthusiast
Enthusiast

Hello Gaprofitt17.

What properties do you want to get?

0 Kudos