April 24, 2024

SamTech 365

PowerPlatform, Power Apps, Power Automate, PVA, SharePoint, C#, .Net, SQL, Azure News, Tips ….etc

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 PowerShell script requires the following:

  1. Microsoft Teams module for powershell  available from:
    1. Install the Microsoft Teams PowerShell module via PowerShell Gallery(recommended option).
    2. Install the Microsoft Teams PowerShell module via Manual Download.
  2. 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
}

 

2