title: Invoke-DbaQuery in a Loop With Just One Set of Headers
body: <p>I'm running <code>Invoke-DBAQuery</code> with <code>Format-Table</code> in a loop to get system configs from various servers. Each run is writing out its own headers though. Using <code>-HideTableHeaders</code> means I get no headers at all. How can I get just the first set of headers and then not for the rest? All servers are running the same version of SQL so there won't be additional headers for different servers.</p>
  <pre><code>$Servers = 'ServerA','ServerB'
  Clear-Variable -Name Data 
  $Data
  
  ForEach ($Server in $Servers) 
  {
  $Data += Invoke-DbaQuery -SqlInstance $Server -Query &quot;Declare   @List Varchar(Max)
  
  Select      @List = Coalesce(@List + ',', '') + Concat('[',Name,']')
  From        sys.Configurations
  Order By    Name
  
  
  
  Declare @SQL Varchar(Max) =
  'Select     @@ServerName as Server
              --,Row_Number() Over (Order By GetDate()) As RowNum
              ,*
  From        (
              Select      Name
                          ,Value 
              From        sys.configurations
              ) sq
      Pivot   (
              Max(Value)
              For Name In (' + @List + ')
              ) piv'
  
  Exec (@SQL)&quot; | Format-Table #-HideTableHeaders
  }
  
  
  $Data
  </code></pre>