6 Replies Latest reply on Sep 9, 2013 6:27 PM by AlbertWT Branched from an earlier discussion.

    Re: Documentation Report on all advanced settings in vCenter

    LucD Guru
    vExpertCommunity WarriorsUser Moderators

      Ok, I think I understood what you are trying to do.

      I took that code and changed it slightly.

      Have a look and feel free to ask if some parts are not clear.

       

      $vcenter = '192.168.0.1'
      Connect-VIServer -Server $vcenter
      $vpx = Get-View -Id 'OptionManager-VpxSettings'
      $rowCount = $vpx.Setting.Count
      $colNames = $vpx.Setting | Select -First 1 | Get-Member -MemberType Property |
      where {$_.Name -notmatch "^Dynamic"} | Select -ExpandProperty Name
      $colCount = $colNames.Count

      $msWord = New-Object -ComObject Word.Application
      $wordDoc = $msWord.Documents.Add()
      $msWord.Visible = $true
      $wordDoc.Activate()

      $doctable = $wordDoc.Tables.Add($wordDoc.Application.Selection.Range,$rowCount + 1,$colCount)

      # Header
      for($col = 0; $col -lt $colCount; $col++){
       
      $cell = $doctable.cell(1,$col + 1).Range
       
      $cell.font.bold = $true
       
      $cell.InsertAfter($colNames[$col])
      }


      # Data
      for($row = 0; $row -lt $rowCount; $row++){
       
      for($col = 0; $col -lt $colCount; $col++){
         
      $cell = $doctable.cell($row + 2,$col + 1).Range
         
      $cell.font.bold = $true
         
      $cell.InsertAfter($vpx.Setting[$row].$($colNames[$col]))
        }
      }

      #Table formatting stuff
      $doctable.columns.autofit()
      Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz