Microsoft Teams is a popular collaboration tool, relied upon by many organizations. But managing that service can be time-consuming for the IT department, especially in a large business. Luckily, administrators have a tool to manage and automate Teams admin tasks.
IT administrators can create new teams, add users to a team, set policies and more, all from the PowerShell command line or via scripts. Here’s how to do it.
1. Connect to Teams
Before you can manage Microsoft Teams with PowerShell, you must first download and install the Microsoft Teams PowerShell module. In your PowerShell console, run the Install-Module cmdlet and provide the name of the Teams module: Install-Module -Name MicrosoftTeams
Once installed, you must then authenticate to the Teams environment using the Connect-MicrosoftTeams cmdlet. This will prompt you for your Microsoft account with permission to manage Teams: Connect-MicrosoftTeams
2. Create a New Team
One popular task in large organizations is creating new teams. Let’s save some time by quickly provisioning the team with the New-Team cmdlet. Simply provide the name of the visibility team to create along with an optional description and visibility. Setting the Visibility parameter to Public tells Teams that all users should see this team while browsing for a team to join: New-Team -DisplayName “Project Managers” -Description “Updates for Important Projects” Visibility
Click the banner below to unlock exclusive cloud content when you become an Insider.
3. Add a User to a Team
A team isn’t very useful until users join. If a team needs dozens or even hundreds of members, PowerShell will make quick work of adding users with the Add-TeamUser cmdlet. This requires two parameters: the GroupId parameter representing the team to add a user to, and the User parameter representing the user principal name (UPN) of the user being added to the team.
First, find the group ID by running the Get-Team cmdlet: Get-Team | Select-Object -Property GroupId, DisplayName
Next, provide the group ID and the UPN of the user to add to the Add-TeamUser cmdlet, and you should soon see a new user in the team: Add-TeamUser -GroupId [Insert ID] -User [Insert User]
4. Disconnect from Teams
When connecting to Teams with the Connect-MicrosoftTeams cmdlet, the cmdlet places a security token on your computer. When all tasks are complete, ensure that the security token is removed by running the Disconnect-MicrosoftTeams cmdlet: Disconnect-MicrosoftTeams.
Once disconnected, the bad guys can’t hijack the session, and the Teams management tasks are complete.