title: Create Union of Multiple Tables in Powershell
body: <p>I'm trying to create a union of multiple tables in Powershell to output in a user-friendly format as a report, similar to a <code>UNION</code> query in SQL.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>$ft = @{auto=$true; Property=@("MachineName", "Status", "Name", "DisplayName")}
  $hosts = @("svr001", "svr002")
  $report = @()
  ForEach ($h in $hosts) {
      $results = Get-Service -CN $h -Name MyService
      $report += $results | Format-Table @ft
      # Other things occur here, which is why I'm creating $report for output later.
  }
  Write-Output $report
  </code></pre>
  
  <p>The output of this code is as follows:</p>
  
  <pre><code>MachineName  Status Name       DisplayName
  -----------  ------ ----       -----------
  svr001      Running MyService  MyServiceDisplayName
  
  
  
  MachineName  Status Name       DisplayName
  -----------  ------ ----       -----------
  svr002      Running MyService  MyServiceDisplayName
  </code></pre>
  
  <p>Since you simply add arrays to do a union in Powershell (i.e.,
  <code>$union = @(0, 1, 2) + @(3, 4, 5)</code>), my initial thought was that I should
  get the following output:</p>
  
  <pre><code>MachineName  Status Name       DisplayName
  -----------  ------ ----       -----------
  svr001      Running MyService  MyServiceDisplayName
  svr002      Running MyService  MyServiceDisplayName
  </code></pre>
  
  <p>In retrospect, I think I understand why I do <strong>not</strong> get this output, but I'm
  unclear how to create a union of the two tables from the first output example into a single table as in the second, and I haven't been able to locate anything in the docs or examples online that would send me in the right direction.</p>