title: How can I export info used to gather Teams users?
body: <p>I want to look up which users populate which teams and export the info to a csv. I am able to get the user info, but I want to preserve info for which Team they occupy. So far, I am only able to export the last entry from my source csv to my exported data.</p>
  <pre><code>#Import Teams list from importFile.csv
  $Teams = Import-CSV &quot;importFile.csv&quot;
  
  #Capture Team names for later export
  $Teams | Select-Object 'TeamDesc' | ForEach-Object {$teamName = $_.TeamDesc}
  
  #Iterate through list
  ForEach($Team in $Teams)
  {
  #Get Team GroupID from TeamDesc column  
  $GroupId = (Get-Team -DisplayName $Team.'TeamDesc').GroupId 
  
  #Get Team user info, select values, and export to destinationFile.csv    
  Get-TeamUser -GroupId $GroupId -Role 'Member' | Select-Object 'User','Name',$teamName |  Export-CSV -NoTypeInformation &quot;exportFile.csv&quot; -Append
  }
  </code></pre>
  <p>Is there a way to apply the &quot;TeamDesc&quot; info to each of the users it gathers from the respective Teams?</p>