title: Cannot export all users, only one shows up when Importing-CSV File to then Get-ADUser
body: <p>I've only just started to learn PowerShell but I'm banging my head on the wall with this one. When I Import-CSV a list of users to get the userprincipalname on Get-Aduser with the header SamAccountName, I am able to see all the emails on the console:</p>
  
  <pre><code>ForEach ($user in $allUsers)
  { 
  Get-ADUser $user.samaccountname -Properties userprincipalname | select -Property userprincipalname
  }
  </code></pre>
  
  <p>However, when I try to export them to a csv-file only 1 user comes out. I always have a problem when using a foreach loop for this...</p>
  
  <pre><code>ForEach ($user in $allUsers)
  { 
  Get-ADUser $user.samaccountname -Properties userprincipalname | select -Property userprincipalname | export-csv $path -NoTypeInformation
  }
  </code></pre>
  
  <p>I'm always run into this problem when making my foreach loops. I only ever get or change 1 variable. Why is this? x_X Please help!</p>
  
  <p>And my CSV file has a header of SamAccountName and samaccount names. Without exporting I get good data from this code on the console:</p>
  
  <p>user@test.com
  user2@test.com
  etc...</p>