Feb 19 2021 12:00 AM
I want to archive teams in bulk with the id. i am sharing my script. but it is not happening. I am sharing my script.
$a = Import-Csv C:\Users\parveen.kumar\Desktop\a.csv
foreach ($a in $data) {$GroupID = (Set-TeamArchivedState -GroupId $a .id -Archived $a.Archive).GroupID }
The csv file is here:
id,displayName,Archive
03fe83c7-cc3e-403e-bbd3-18f1f7efef42,test for new aca,TRUE
e550eefc-1689-4530-8112-085e6fba1c8c,VIB,TRUE
Feb 19 2021 04:45 AM
@parveenprajapati Set-TeamArchivedState's -Archived parameter expects a boolean value, so would need to be called as "-Archived:$true" (or $false). The easiest way round this is to just put the teams you want to archive in the CSV. You've also got an error in the foreach where data never gets anything assigned to it.
I'd have thought the below would work:
$csv = Import-Csv C:\Users\parveen.kumar\Desktop\a.csv
foreach ($team in $csv) {
Set-TeamArchivedState -GroupId $team.id -Archived:$true
}
Feb 19 2021 08:08 PM
@CoasterKaty Thanks Katy, the script is working fine. I have an another query. I have more then 2400 teams and for my school and I want to archive teams time to time in the end of the session with keyword like '2020', 'Class-VI-A', 'ICT', 'PA'. Is there any possibility in PowerShell to archive with keywords.
Feb 20 2021 12:53 PM
@parveenprajapati You could do something like:
Get-Team | Where {$_.DisplayName -like "*2020*" | Set-TeamArchivedState -Archived:$true
although if you're using Teams for school classes I'd recommend looking at School Data Sync for next year as it handles the creation/update/archival of teams for you.
Feb 22 2021 12:12 AM
@CoasterKaty Thank you for your help. Its working now.
Jan 25 2022 04:21 AM
You can use this script: https://m365scripts.com/microsoft-teams/how-to-archive-team-in-microsoft-teams/#archive-teams-in-bul...
In this script, you can directly use the teams' name instead of id in the CSV file.