title: PowerShell HTML report output format
body: <p>I need some help on the report output for a PowerShell script I'm putting together. The script get's information from a computer on the following items.</p>
  
  <p>Last Rebooted by
  Uptime
  Pending Reboot
  Patching Information</p>
  
  <p>The problem I'm having is with the "Patching Information" output. The information I want returned under this heading is "Hotfixid","description","installedby","installedon"</p>
  
  <p>If I specify one value such as "Updates.hotfixid" I get the results but If I try adding the others I get returned System.Object[] System.Object[].</p>
  
  <p>Also the output under this heading wraps but i'd like it to list. </p>
  
  <p>Below is the script</p>
  
  <pre><code>    $comps = Get-Content 'c:\temp\comp.txt'
  
      $total = $null
  
      $html = @'
      &lt;html&gt;
      &lt;head&gt;
      &lt;meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'&gt;
      &lt;title&gt; Server Maintenance Report&lt;/title&gt;
      &lt;STYLE TYPE="text/css"&gt;
      &lt;!--
      td {
      font-family: Tahoma;
      font-size: 13px;
      border-top: 1px solid #999999;
      border-right: 1px solid #999999;
      border-bottom: 1px solid #999999;
      border-left: 1px solid #999999;
      padding-top: 0px;
      padding-right: 0px;
      padding-bottom: 0px;
      padding-left: 0px;
      }
      body {
      margin-left: 5px;
      margin-top: 5px;
      margin-right: 0px;
      margin-bottom: 10px;
  
      table {
      border: thin solid #000000;
      }
      --&gt;
      &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;table width='100%'&gt;
      &lt;tr bgcolor='#CCCCCC'&gt;
      &lt;td colspan='7' height='25' align='center'&gt;&lt;strong&gt;&lt;font color="#003399" size="4" face="tahoma"&gt; Report &lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;table width='100%'&gt;&lt;tbody&gt;
            &lt;tr bgcolor=#CCCCCC&gt;
            &lt;td width='14%' height='15' align='center'&gt; &lt;strong&gt; &lt;font color="#003399" size="2" face="tahoma" &gt;Server Name&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;
            &lt;td width='14%' height='15' align='center'&gt; &lt;strong&gt; &lt;font color="#003399" size="2" face="tahoma" &gt;Last Rebooted By&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;
            &lt;td width='16%' height='15' align='center'&gt; &lt;strong&gt; &lt;font color="#003399" size="2" face="tahoma" &gt;Uptime&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;
            &lt;td width='8%' height='15' align='center'&gt; &lt;strong&gt; &lt;font color="#003399" size="2" face="tahoma" &gt;Pending Reboot&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;
            &lt;td width='50%' height='15' align='center'&gt; &lt;strong&gt; &lt;font color="#003399" size="2" face="tahoma" &gt;Patching Information&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;
            &lt;/tr&gt;" 
      &lt;/table&gt;
      &lt;table width='100%'&gt;&lt;tbody&gt;
      '@
  
      Function Uptime($comp){
              function WMIDateStringToDate($Bootup) {
               [System.Management.ManagementDateTimeconverter]::ToDateTime($Bootup)
              }
              $NameSpace = "Root\CIMV2"
              $wmi = [WMISearcher]""
              #$wmi.options.timeout = '0:0:30' #set timeout to 30 seconds
              $query = 'Select * from Win32_OperatingSystem'
              $wmi.scope.path = "\\$comp\$NameSpace"
  
              $wmi.query = $query
              Try{
                  $wmiresult = $wmi.Get()
                  foreach ($wmioutput in $wmiresult){
                     $Bootup = $wmioutput.LastBootUpTime
                     $LastBootUpTime = WMIDateStringToDate($Bootup)
                     $now = Get-Date
                     $Reporttime = $now - $lastBootUpTime
                     $d = $Reporttime.Days
                     $h = $Reporttime.Hours
                     $m = $Reporttime.Minutes
                     $time = "Up for: {0} days, {1} hours, {2:N0} minutes" -f $d,$h,$m
                     return $time 
                  }
              }
              Catch [Exception] {
                  $uperr = '&lt;font color="#FF0000"&gt; RPC Issue : &lt;/font&gt;'+ $_
                  return $uperr 
              }
          }
  
      Function RebootedBy($comp){
              try {
              gwmi win32_ntlogevent -filter "LogFile='System' and EventCode='1074' and Message like '%restart%'" -ComputerName $comp | 
              Where {$_.ConvertToDateTime($_.TimeGenerated) -gt $lastBootUpTime}  | 
              select User,@{n="Time";e={$_.ConvertToDateTime($_.TimeGenerated)}} -First 1
              }
              Catch [Exception] {
                  $uperr = '&lt;font color="#FF0000"&gt; RPC Issue : &lt;/font&gt;'+ $_
                  return $uperr 
              }
          }
  
  
      Function Updates ($comp){
              try {
              $date = Get-Date '26/09/2013'
              (Get-HotFix -ComputerName $comp| where-object {$_.hotfixid -ne "file 1"} | where "InstalledOn" -gt $date | Select hotfixid,description,installedby,@{l="InstalledOn";e={[DateTime]::Parse($_.psbase.properties["installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}} )
              }
              Catch [Exception] {
                  $uperr = '&lt;font color="#FF0000"&gt; RPC Issue : &lt;/font&gt;'+ $_
                  return $uperr 
              }
           }
  
  
      function PendingReboot ($comp){
          process {
              try {
                  $WMI_OS = ""
                  $RegCon  = ""
                  $WMI_OS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $comp -ErrorAction Stop
                  if ($?){
                  try{ 
                      $RegCon = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"LocalMachine",$comp) 
                      If ($WMI_OS.BuildNumber -ge 6001){ 
                          $RegValueSetupex = ""
                          $RegValuePFRO2k8 = ""
                          $RegSubKeySM = $RegCon.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\") 
                          $RegValueSetupex = $RegSubKeySM.GetValue("SetupExecute",$null) 
                          if ($RegValueSetupex){
                              $RegValueSetupex = $true
                          }
  
                          $RegSubKeySM = $RegCon.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\") 
                          $RegValuePFRO2k8 = $RegSubKeySM.GetValue("PendingFileRenameOperations",$null) 
                          if ($RegValuePFRO2k8 ){
                              $RegValuePFRO2k8  = $true
                          }
  
                          $RegCon.Close()
  
                          if ( $RegValueSetupex -eq $true -or $RegValuePFRO2k8 -eq $true){
                              return '&lt;font color="#FF0000"&gt;'+$true
                          }
                          else {
                              return $false                           
                          }
                      }
                      else{   
                          $RegValuePFRO2k3 = $false;
                          $RegCon = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"LocalMachine","$comp") 
                          $RegSubKeySM = $RegCon.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\") 
                          $RegValuePFRO2k3 = $RegSubKeySM.GetValue("PendingFileRenameOperations",$null) 
                          $RegCon.Close()
                          If ($RegValuePFRO2k3) { 
                              return  '&lt;font color="#FFFF00"&gt;'+$true; 
                          }
                          else {
                              return $false; 
                          } 
                      }
  
                  }
                  catch {
                      return '&lt;font color="#7CFC00"&gt;'+"Remote Registry Service OK"
                  }
                  }
                  else {
                      throw $error[0].Exception
                  }
              }   
              catch {
                      return '&lt;font color="#FF0000"&gt;'+"RPC Issue"         
              }
          }
      }
  
  
      $i=0 # for Progress bar
  
      foreach($comp in $comps){
          $i++
          $ErrorActionPreference = "SilentlyContinue" 
          Write-Progress   -Activity "Report v1.0" -Status ("Checking : {0}" -f $comp) -PercentComplete ($i/$comps.count*100) -Id 0 
          $ErrorActionPreference = "Continue"
          #region Var_Nulling :p  
          $Reporttimestatus  = $null
  
          #endregion
          $Reporttimestatus = uptime -comp $comp
          $RebootedBy = RebootedBy $comp
          $Pending = PendingReboot -comp $comp
          $Updates = Updates -comp $comp
  
          $newobj = $null
          $newobj = new-object psobject
          $newobj | add-member -membertype noteproperty -name "Server" -value $comp 
          $newobj | add-member -membertype noteproperty -name "Uptime" -value $Reporttimestatus
          $newobj | add-member -membertype noteproperty -name "RebootedBy" -value $RebootedBy.User , $RebootedBy.Time
          $newobj | add-member -membertype noteproperty -name "PendingReboot" -value $Pending
          $newobj | add-member -membertype noteproperty -name "Updates" -value $Updates.hotfixid
          #, $Updates.description , $Updates.installedby , $Updates.InstalledOn
  
          $htmlserver = $newobj.Server
          $htmluptime = $newobj.Uptime
          $htmlrebootedby = $newobj.RebootedBy
          $htmlpendingreboot =  $newobj.PendingReboot
          $htmlupdates = $newobj.Updates
  
      $current = "
              &lt;tr bgcolor=#CCCCCC&gt;
              &lt;td width='14%' align='center'&gt;$htmlserver&lt;/td&gt;
              &lt;td width='14%' align='center'&gt;$htmlrebootedby&lt;/td&gt;
              &lt;td width='16%' align='center'&gt;$htmluptime&lt;/td&gt;
              &lt;td width='8%' align='center'&gt;$htmlpendingreboot&lt;/td&gt;
              &lt;td width='50%' align='left'&gt;$htmlupdates&lt;/td&gt;
              &lt;/tr&gt; "
  
          $total += $current
  
      }
  
      $HTMLEnd = @"
      &lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
      "@
  
      $MainHtml= $html + $total + $HTMLEnd
      $MainHtml  | Out-File "c:\temp\Report.html" -Append
  </code></pre>