September 28, 2022

Samir Daoudi's Technical Blog

SharePoint, Office 365, C#, .Net, SQL Server News, Tips, Ebooks, Events, Webinars ….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
}

 

Leave a comment

You may have missed

Show Buttons
Hide Buttons

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

%d bloggers like this: