So in writing a script for Vcloud Director, I want to be able to see who "owns" a VM. It seems like I cannot get the vapp information from the VM.
Any ideas? Below is some of the code that I am working on:
foreach($vm in get-CiVM){
$vapp = get-Civapp | $VM
$row = "" | Select "Name", "VApp", "Org", "Status", "Operating System", "CpuCount", "Memory (GB)", Owner
$row."Name" = $_.Name
$row."Vapp" = $Vapp.Name
$row."Org" = $Vapp.Org
$row."Status" = $_.Status
$row."Operating System" = $_.GuestOSFullName
$row."CpuCount" = $_.CpuCount
$row."Memory (GB)" = ($_ | Measure-Object -Property MemoryMB -Sum).Sum/1024
$row.Owner = $vapp.Owner
If we iterate through vapps showing the vapp properties first, it will only retreve the first VM in the vapp, making the data incomplete... so we are forced to get all the VMs, then try to retrieve the vapp info - such as owner and eventually the "sizeGB" info as well.
This will show what I want, but does not retreive ALL of the VMs.
foreach($Vapp in Get-CiVapp -Name $vapp){
$vm = $vapp | get-civm
if($vm) {
$vm | %{
$row = "" | Select "Name", "VApp", "Org", "Status", "Operating System", "CpuCount", "Memory (GB)", Owner
$row."Name" = $_.Name
$row."Vapp" = $Vapp #we know the vapp already
$row."Org" = $_.Org
$row."Status" = $_.Status
$row."Operating System" = $_.GuestOSFullName
$row."CpuCount" = $_.CpuCount
$row."Memory (GB)" = ($_ | Measure-Object -Property MemoryMB -Sum).Sum/1024
$row.Owner = $vapp.Owner
Any help is much apprciated!