Hi All, Anyone have an updated version of this script? Appreciate the help!
$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
You can do the same
$row."Owner" = $CIvapp.Owner.Name -join '|'
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The results come out as below with System.Object and do not pull the details..
Name | CIVApp | Org | Status | Operating System | CpuCount | Memory (GB) | Owner |
svr2012r2 | System.Object[] | System.Object[] | System.Object[] | Microsoft Windows Server 2012 (64-bit) | 2 | 4 | System.Object[] |
svr2012r2 | System.Object[] | System.Object[] | System.Object[] | Microsoft Windows Server 2012 (64-bit) | 2 | 4 | System.Object[] |
svr2012r2 | System.Object[] | System.Object[] | System.Object[] | Microsoft Windows Server 2012 (64-bit) | 2 | 4 | System.Object[] |
Server_2012_R2_Update_x64 | System.Object[] | System.Object[] | System.Object[] | Microsoft Windows Server 2012 (64-bit) | 2 | 4 | System.Object[] |
The Export-Csv cmdlet can't handle properties that are arrays (multiple values).
Try like this
$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
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!
You can do the same
$row."Owner" = $CIvapp.Owner.Name -join '|'
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc!! As always, you nailed it.