title: Powershell : Display the table headers once at the top in a html report
body: <p>I am trying to create an email report to display a list of failed/succeeded backup jobs.</p>
  
  <p>Here is my script:</p>
  
  <pre><code>$servers = @(gc config\dbs.txt)
  foreach($server in $servers)
  {
    $dt = new-object "System.Data.DataTable"
    $cn = new-object System.Data.SqlClient.SqlConnection "server=$server;database=msdb;Integrated Security=sspi"
    $cn.Open()
    $sql = $cn.CreateCommand()
    $sql.CommandText = $(get-content config\query.sql)
    $rdr = $sql.ExecuteReader()
    $dt.Load($rdr)
    $cn.Close()
    $dt |ft Server,RunStatus,JobName &gt;&gt; $log
    $dt | ConvertTo-Html Server,JobName,RunStatus -head $a | ac logs\backups\report.htm    
  }
  
  Server      JobName     RunStatus
  srv1        job1        success
  srv1        job2        success
  Server      JobName     RunStatus
  srv2        job1        fail
  srv2        job2        success
  srv2        job3        success
  Server      JobName     RunStatus
  srv3        job1        fail
  srv3        job2        success
  srv3        job3        success
  Server      JobName     RunStatus
  srv4        job1        fail
  srv4        job2        success
  srv4        job3        success
  Server      JobName     RunStatus
  srv5        job1        fail
  </code></pre>
  
  <p>I am getting the header names multiple times as the content to the html file is being added after every foreach enumeration. Can I change my script so that the header [Server JobName RunStatus] is only displayed once at the top?</p>
  
  <p>Also I want to know if it is possible to display the report.htm as inline content in the mail rather than an attachment. Is this possible?</p>
  
  <p>Thanks in advance.<br>
  steeluser</p>