5 Replies Latest reply on Jun 29, 2018 1:24 PM by BG_ESET

    VCD 8.2 VM & vAPP Owner Report

    BG_ESET Lurker

      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

        • 1. Re: VCD 8.2 VM & vAPP Owner Report
          BG_ESET Lurker

          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[]
          • 2. Re: VCD 8.2 VM & vAPP Owner Report
            LucD Guru
            Community WarriorsvExpertUser Moderators

            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

            • 3. Re: VCD 8.2 VM & vAPP Owner Report
              BG_ESET Lurker

              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!

              • 4. Re: VCD 8.2 VM & vAPP Owner Report
                LucD Guru
                User ModeratorsCommunity WarriorsvExpert

                You can do the same

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

                • 5. Re: VCD 8.2 VM & vAPP Owner Report
                  BG_ESET Lurker

                  Thanks Luc!! As always, you nailed it.