Set all the Microsoft Teams to Private using PowerShell
In this script, we will look at setting all the Teams to private. As a lot of users would have created Teams without bothering to think who needs to be added to them.
A quick fix to this potential risk (of data leak), is to set all the teams to private and then work with the Teams’ Owners to set the right members for each team.
In the previous script, I was able to export all the teams’ owners and members to a csv file, which can be used to drive the comms.
Set all the teams to private
Requirements
The following script requires the following:
- Microsoft Teams module for powershell available from:
- Install the Microsoft Teams PowerShell module via PowerShell Gallery(recommended option).
- Install the Microsoft Teams PowerShell module via Manual Download.
- Having Teams or Tenant admin rights.
Once these two requirements were in place, time for the action:
The script
Get-Team | foreach { $GroupId=$_.GroupId Set-Team -GroupId $GroupId -Visibility Private }