The Microsoft Teams admin portal has been unresponsive since the start of the year and that has made it difficult to archive last years Teams. The official Microsoft process hasn’t worked for me so I wrote the script below to archive teams through PowerShell.
First, get a list of the Teams from your tenant.
Connect-MicrosoftTeams Get-Team | Export-csv c:\temp\teams.csv
Next, you’ll want to remove any teams that you don’t want to archive – also remove the first line of the CSV file so that the headers are the top row.
Then you can run the script below to step through the CSV file and archive the teams.
# If you need to load a different file change it below here $csv = "teams.csv" # Declare user array $teamsArray = @() # Import the CSV license file $teamsArray = Import-CSV $csv $count = 0 # Step through the array and start archiving teams foreach ($team in $teamsArray) { try { Write-Host "Attempting to archive" $teamsArray[$count].DisplayName Set-TeamArchivedState -GroupId $teamsArray[$count].GroupId -Archived:$true Write-Host -ForegroundColor Green "Archived" $teamsArray[$count].DisplayName } catch { # Something has gone horribly wrong Write-Host -ForegroundColor Red "Something went wrong and the team wasn't archived" $teamsArray[$count].DisplayName } $count ++ }