title: Constructing a table from raw data in powershell
body: <p>I am frustrated beyond belief with Powershell at the moment, because I feel stupid for spending 2 whole work days figuring out a (most likely super simple) solution for the following problem: I would like to convert two arrays (<code>$HeaderCells</code>, <code>$DataCells</code>) into a table and nothing seems to work. I tried PSObjects, Arrays, Hash Tables, data tables... Here is my code:</p>
  
  <pre><code>$Table = @()
  $HeaderCells = @("Company","Country")
  $DataCells = @("Test Inc.","Misc Corp.","USA","UK")
  
  foreach ($HeaderCell in $HeaderCells)
  {
      foreach ($DataCell in $DataCells)
      {
          $Table += New-Object -TypeName PSObject -Property @{$HeaderCell=$DataCell}
      }
  }
  $Table
  </code></pre>
  
  <p>my Output is:</p>
  
  <pre><code>Company   
  -------   
  Test Inc. 
  USA       
  Misc Corp.
  UK       
  </code></pre>
  
  <p>I would like to get two columns (Company and Country), but no matter what I try (even the most nested for loops, I always end up overwriting variables or just getting errors.</p>
  
  <p>My actual use case is actually a bit more complicated (extracting a table from a html page), but solving this part will allow me to continue, I hope.</p>
  
  <p>My desired output would be to have the HeaderCells as the Headers and the DataCells as the Rows, so something like this:</p>
  
  <pre><code>Company     Country
  -------           --------
  Test Inc.       USA 
  Misc Corp.  UK
  </code></pre>