Forum Discussion
Want to archive teams in bulk
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
}
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.
- CoasterKatyFeb 20, 2021MVP
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.
- parveenprajapatiFeb 22, 2021Copper Contributor
CoasterKaty Thank you for your help. Its working now.