Quantcast
Channel: VMware Communities : Popular Discussions - vCloud Director PowerCLI
Viewing all articles
Browse latest Browse all 13334

Vm - Vapp owner

$
0
0

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!


Viewing all articles
Browse latest Browse all 13334

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>