How to remove all members and channels from your Microsoft Teams

Posted on 21 September 2021

TL;DR Do you use Microsoft Teams in your organization and you need to remove (almost) everything from a team? Read this!

If you are using Microsoft Teams for your classes, as we are doing at University of Calabria, these few words may save your day! New year, new classes, old teams… what are you going to do with your old students? It’s very unlikely that they want to receive notifications of any kind for courses that they already passed. An easy solution can be to create a new team every year, but at least in our case we have been asked to keep previous teams.

For some reason, the user interface of Microsoft Teams doesn’t provide any bulk action to delete more than one member at time. Fortunately, the user interface now doesn’t ask confirmation, which can be quite dangerous most of the time, but may save some minutes the one-per-year time you need to remove everyone! Anyhow, it’s still a lot of time to click all those members, and if you also want to delete all channels, in that case you are also asked for a confirmation. What a nightmare!

Let’s use the PowerShell to automate these jobs. If it’s the first time you use the PowerShell to interact with Microsoft Teams, I suggest to have a look at my previous post on How to remove yourself from any team of Microsoft Teams. The idea is the same: you authenticate with your Microsoft Teams account, provide a team name as a command-line parameter, and all non-owner members or channels are removed. Note that Microsoft Teams may require some time to reflect the update in its user interface.

$ ./remove-all-members-from-this-team.ps1 "Secure Software Design"
$ ./remove-all-channels-from-this-team.ps1 "Secure Software Design"

If you get some error, please first try to run the script from my previous post.

I hope that this may help you! The scripts can be downloaded here:

remove-all-members-from-this-team.ps1, remove-all-channels-from-this-team.ps1