Manage Microsoft Teams quickly and easily with PowerShell

Many businesses have made the move to Microsoft 365, and many others have been making plans to migrate to the cloud platform. But as the COVID-19 pandemic transforms how people work and from where they work, some companies accelerated their Microsoft 365 migration plans. So, it’s not surprising that Microsoft has recently reported an uptick in companies using Microsoft Teams, which is an integral part of Microsoft 365. Microsoft makes it easy to manage Teams through its dedicated admin center portal. But if you’re an IT administrator who likes to roll up your sleeves and fire up PowerShell to knock off a bunch of daily tasks quickly and efficiently, why not use your scripting skills to manage Microsoft Teams.

Manage Microsoft Teams

Installing the Microsoft Teams PowerShell module

This tip on how to manage Microsoft Teams with PowerShell comes to us courtesy of Teams guru Anthony Bartolo, a senior cloud advocate for Microsoft. To get the ball rolling, launch PowerShell as an administrator and begin by installing the Microsoft Teams PowerShell module:

Install-Module -Name MicrosoftTeams

Depending on your system, you may be asked by PowerShell to allow it to install some additional packages and modules. Next, log in to your Teams tenant with this cmdlet:


Note: You can always get a list of PowerShell Microsoft Teams cmdlets by typing Get-TeamHelp.

The cmdlets you will probably be using the most are:

  • New-Team (creates a new Team)
  • Remove-Team (erases a Team)
  • Add-teamuser (adds a user to an existing Team)
  • Remove-teamuser (removes a user from an existing Team)

Manage Microsoft Teams with PowerShell: Sample script

There are several tasks you can accomplish using PowerShell to manage Microsoft Teams. Here’s a script from Bartolo allowing you to assign custom policies to a user or multiple users:

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

What does the script do? Bartolo explains it on Microsoft’s ITOps Talk Blog, where he notes that the script “assigns the Human Resources Management Policy to all users in the Human Resources group. The script begins by getting the GroupObjectId of the group. Once acquired, it then finds the members of that group and assigns the policy to all users in the group.” You can easily alter his script for your purposes.

More Teams resources

Bartolo’s script is just one example of how you can use PowerShell to manage Microsoft Teams. For those who prefer to manage Microsoft Teams via the Teams admin center portal instead of PowerShell, TechGenix’s Amy Babinchak has some information on configuring Teams here and here. Brien Posey has two excellent tutorials: setting up access for Microsoft Teams guest users and, to make your communications sound better, using the Microsoft Teams call quality dashboard. And don’t miss Sukesh Mudrakola’s helpful article where he looks at top Teams features to improve work collaboration.

Featured image: Shutterstock

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top