title: Export hashtable to CSV with the key as the column heading
body: <p>I have a script to create a hashtable with usernames as the key and an array of their groups as the value.</p>
  
  <p>Here is what it looks like:</p>
  
  <pre>Name                           Value
  ----                           -----
  user1                          {Domain Users, group2, group3}
  user2                          {Domain Users, group4}
  user3                          {Domain Users, group2, group3, group4}</pre>
  
  <p>How can I export this into a CSV file using the username as the heading?</p>
  
  <p>When I import the CSV file into Excel I want it to look like this:</p>
  
  <pre>     A              B             C
    -------------------------------------------
  1 | user1         user2         user3
  2 | Domain Users  Domain Users  Domain Users
  3 | group2        group4        group2
  4 | group3                      group3
  5 |                             group4</pre>
  
  <p>I have played around with <code>Export-Csv</code> but cannot get it to work for this type of hashtable.</p>