title: How to add/combine output to existing an array in PowerShell?
body: <p>My <code>$file</code> contains two columns. Using the username in <code>.</code>, I would like to add <code>name</code> and <code>givenname</code> as the third and fourth columns respectively.  So far I have:</p>
  
  <pre><code>$file = Import-Csv H:\computers2userswoSP1.csv
  $out = foreach ($o in $file.name) {
      Get-ADUser $o | select name, givenname
  }
  </code></pre>
  
  <p>I tried adding the code below into the first <code>foreach</code>, but that didn't work:</p>
  
  <pre><code>foreach ($r in $out) {
      New-Object PSObject -prop @{
          name = $file.fullname
          givenname = $file.Firstname
      }
  }
  </code></pre>
  
  <p>and also adding this before the loops:</p>
  
  <pre><code>Add-Member -InputObject $file -TypeName fullname
  Add-Member -InputObject $file -TypeName Firstname
  </code></pre>
  
  <p>with this in the loop:</p>
  
  <pre><code>$out.givenname += $file.FirstName
  $out.name += $file.
  </code></pre>
  
  <p>As you can see, I'm shooting in the dark a little. Any recommendations?</p>