Forum Discussion
Curious_Kevin16
Oct 17, 2024Iron Contributor
Convert large number of Public Teams to Private
Howdy Folks, We currently have a substantial number of public Teams in our environment and would like to convert as many of these to private as possible as part of our security and compliance rem...
deanshepherd
Oct 17, 2024Brass Contributor
Curious_Kevin16
You can use the teams powershell module sothing like this
# Install the MicrosoftTeams module if not already installed
Install-Module -Name MicrosoftTeams -Scope CurrentUser
# Import the module
Import-Module MicrosoftTeams
# Connect to Microsoft Teams
$credential = Get-Credential
Connect-MicrosoftTeams -Credential $credential
# Get the team you want to update
$teamName = "Your Team Name"
$team = Get-Team -DisplayName $teamName
if ($team) {
$teamId = $team.GroupId
# Update the team to private
Set-Team -GroupId $teamId -Visibility Private
Write-Output "The team '$teamName' has been updated to private."
} else {
Write-Output "Team '$teamName' not found."
}
# Disconnect from Microsoft Teams
Disconnect-MicrosoftTeams
For each team you set as private, you are probably going to have to set its membership as well here is how you can do that https://learn.microsoft.com/en-us/powershell/module/teams/set-teammembersettings?view=teams-ps add Set-TeamMemberSettings after Set-Team visibility
hope this helps
D