I am trying to take an existing CSV file and append it with the output from another command. Whenever I run the script, it sets all values in the column to the $owner.
I'm not sure what I'm missing, but it is not working properly.
`Connect-MicrosoftTeams
#get list of teams
$TeamsFile = Get-Team | Select DisplayName, GroupID, Description | Export-CSV -Path "C:\Scripts\Microsoft_Teams_List.csv" -Delimiter "," -NoTypeInformation
#read row in CSV, add owner to new column.
ForEach ($Team in $TeamsFile) {
$Owner = Get-TeamUser -GroupId $Team.GroupID -Role Owner | Select Name
Write-Host $Team.GroupID " Owner: " $Owner.name
$TeamsFile = Import-CSV -Path "C:\Scripts\Microsoft_Teams_List.csv"
$TeamsFile | Select-Object -Property *, @{label = 'Team Owner'; expression = {$Owner.name}}
}
$TeamsFile | Export-CSV -Path "C:\Scripts\Microsoft_Teams_List.csv" -Delimiter "," -NoTypeInformation
`

$TeamsFileto contain anything, you should useGet-Team | Select DisplayName, GroupID, Description -OutVariable TeamsFile | Export-CSV -Path "C:\Scripts\Microsoft_Teams_List.csv" -Delimiter "," -NoTypeInformation