Managing Microsoft Teams Using PowerShell

Microsoft Teams can be managed through its Admin Center, using PowerShell or via the Graphs API. In this article, you will learn the most common cmdlets to manage Microsoft Teams communication and collaboration for your organization.

Before you start, check which Microsoft Teams administrator role you have, because access to different cmdlets depends on the role you are assigned in Azure Active Directory (Azure AD).

There are four Microsoft Teams admin roles:

  • Global Administrator or Teams Service Administrator — Can manage and create a Microsoft 365 group and oversee the organization’s Teams service
  • Teams Communications Administrator — Can configure and manage calling and meeting features within Teams
  • Teams Communications Support Engineer — Can troubleshoot communication issues within Teams using advanced tool set, which includes the full list of the Call Analytics features
  • Teams Communications Support Specialist — Can troubleshoot communications issues within Teams with limited access to users’ information (this is the least powerful role)

Getting Started with PowerShell to Manage Microsoft Teams

1. Install the Teams PowerShell module.

Launch a PowerShell window and use the following command:

PS> Install-Module -Name MicrosoftTeams

Alternatively, you can deploy the package directly to Azure Automation or manually download the .nupkg file to your system’s default download location.

2. Sign in.

Use this script to log in to Teams using your username and password for the tenant:


Connect-MicrosoftTeams -Credential $cred

If multi-factor authentication is enabled for your credentials, log in using the following script and then enter your O365 credentials:


To disconnect from the Microsoft Teams environment, use the following command:


3. List the available cmdlets.

To get a list of all available cmdlets, use this command:

PS> Get-TeamHelp

Note that PowerShell allows you to create custom cmdlets as well.

Managing Microsoft Teams Using PowerShell_Listing of available cmdlets

Useful PowerShell Cmdlets for Microsoft Teams

The following cmdlets are necessary to start managing Microsoft Teams via PowerShell:

Create and Manage a Team

Commands for managing a team include:

  • New-team — Create a new team.
  • Get-team — Retrieve a team object with properties, such as all teams that a specific user belongs to.
  • Set-team — Update the properties of a team.
  • Set-TeamPicture — Update the team picture.
  • Remove-team — Remove a team.

Add and Remove Team Members

Commands for managing individual team members include:

  • Add-teamuser — Add a user to the team.
  • Remove-teamuser — Remove a user from the team.

Create and Remove Channels

Commands for basic channel management include:

  • New-TeamChannel — Create a new team channel.
  • Remove-TeamChannel — Remove a team channel.

Manage Policies

Teams policies are used to control what users can do in teams and channels, such as whether they can create private channels. A policy can apply to the entire organization or only to specific users.

Policies can be created and edited using the Teams Admin Center, but you will need to manage policies for each user separately, which can be tedious and error-prone. If you need to apply a custom policy to multiple users, PowerShell is a more convenient tool.

Here is a script that assigns the Accounting Messaging Policy to all users in the Accounting group. It gets the GroupObjectId of the particular group, then gets the members of that group, and then assigns the policy to all those users:

$group = Get-AzureADGroup -SearchString "Accounting group"

$members = Get-AzureADGroupMember -ObjectId $group.ObjectId -All $true | Where-Object {$_.ObjectType -eq "User"}$members | ForEach-Object { Grant-CsTeamsChannelsPolicy -PolicyName "Accounting Messaging Policy" -Identity $_.UserPrincipalName}

For more information about using PowerShell to manage Microsoft Teams, refer to the Microsoft Teams PowerShell documentation.

Jeff is a Director of Global Solutions Engineering at Netwrix. He is a long-time Netwrix blogger, speaker, and presenter. In the Netwrix blog, Jeff shares lifehacks, tips and tricks that can dramatically improve your system administration experience.