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

get-civm command piped to get-civapp | owner

$
0
0

Basically I've been researching to see how I might pull some reporting data from VCD. I ran across several sites that provide exactly what I am needing, but the problem is they all use the get-civm cmdlet which does not include the owner parameter which is what I need. The following script works great, but is there a way to pipe this to include the get-civapp | owner as well? I'm pretty new to Power CLI and I am hitting a wall. Initially I thought I could possibly run the script using the get-civapp cmdlet, but it errors out with a "Exception calling "GetVirtualHardwareSection" with "0" argument(s): "Access is forbidden" error message.

 

Any assistance or direction that you can provide would be greatly appreciated. Here is the script I copied from http://anthonyspiteri.net/?p=954 which references GeekAfterFive - Infrastructure as Code for credit.

 

# Get a list of vCloud Orgs

$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;"Status"=$vm.Status;"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 | get-CIVApp owner| Sort-Object -Property vapp | Format-Table -AutoSize

 

 

Thanks,

Blind


Viewing all articles
Browse latest Browse all 13334

Trending Articles



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