VMware Cloud Community
BG_ESET
Contributor
Contributor
Jump to solution

VCD 8.2 VM & vAPP Owner Report

Hi All, Anyone have an updated version of this script? Appreciate the help!

$CIvApp = get-CIvApp

$CIvms = $CIvApp | get-CIvm 

$report = @() 

foreach($vm in $CIvms){ 

$row = "" | Select "Name", "CIVApp", "Org", "Status", "Operating System", "CpuCount", "Memory (GB)", "Owner" 

   $row."Name" = $vm.Name 

   $row."CIvapp" = $CIVapp.Name 

   $row."Org" = $CIVapp.Org.Name 

   $row."Status" = $CIVapp.Status 

   $row."Operating System" = $vm.GuestOSFullName 

   $row."CpuCount" = $vm.CpuCount 

   $row."Memory (GB)" = ($vm | Measure-Object -Property MemoryMB -Sum).Sum/1024 

   $row."Owner" = $CIvapp.Owner.Name 

   $report += $row 

$report | export-csv C:\tmp\VcloudVMsNEW.csv

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can do the same

$row."Owner" = $CIvapp.Owner.Name -join '|'


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
5 Replies
BG_ESET
Contributor
Contributor
Jump to solution

The results come out as below with System.Object and do not pull the details..

      

NameCIVAppOrgStatusOperating SystemCpuCountMemory (GB)Owner
svr2012r2System.Object[]System.Object[]System.Object[]Microsoft Windows Server 2012 (64-bit)24System.Object[]
svr2012r2System.Object[]System.Object[]System.Object[]Microsoft Windows Server 2012 (64-bit)24System.Object[]
svr2012r2System.Object[]System.Object[]System.Object[]Microsoft Windows Server 2012 (64-bit)24System.Object[]
Server_2012_R2_Update_x64System.Object[]System.Object[]System.Object[]Microsoft Windows Server 2012 (64-bit)24System.Object[]
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The Export-Csv cmdlet can't handle properties that are arrays (multiple values).

Try like this

$CIvApp = get-CIvApp

$CIvms = $CIvApp | get-CIvm


$report = @()


foreach($vm in $CIvms){

   $row = "" | Select "Name", "CIVApp", "Org", "Status", "Operating System", "CpuCount", "Memory (GB)", "Owner"

   $row."Name" = $vm.Name

   $row."CIvapp" = $CIVapp.Name -join '|'

   $row."Org" = $CIVapp.Org.Name -join '|'

   $row."Status" = $CIVapp.Status -join '|'

   $row."Operating System" = $vm.GuestOSFullName

   $row."CpuCount" = $vm.CpuCount

   $row."Memory (GB)" = ($vm | Measure-Object -Property MemoryMB -Sum).Sum/1024

   $row."Owner" = $CIvapp.Owner.Name

   $report += $row

}


$report | export-csv C:\tmp\VcloudVMsNEW.csv


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
BG_ESET
Contributor
Contributor
Jump to solution

Thank you Luc!! Appreciate the quick response.

Know of a way to get the vAPP Owner Property come through the report?

Im still getting a System.Object[] value come through on the report..

Thanks Again!

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can do the same

$row."Owner" = $CIvapp.Owner.Name -join '|'


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
BG_ESET
Contributor
Contributor
Jump to solution

Thanks Luc!! As always, you nailed it.

0 Kudos