How to Manage Microsoft Teams using PowerShell

Install the Teams PowerShell Module

The first step in managing Teams via PowerShell is to install the Teams Cmdlets module.  Running PowerShell as an Administrator, you will need to run the following and allow install from the untrusted repo as well as installing the NuGet package:


Install-Module -Name MicrosoftTeams

Manage Microsoft Teams PowerShell Code

Connect PowerShell to the Tenant

The next step is to connect to Teams in the tenant.  This can be done with the following script.

$UserCredential = Get-Credential
Connect-MicrosoftTeams -Credential $UserCredential


Voila…you are connected to Microsoft Teams as long as you have the appropriate rights.

Show Available Cmdlets

You can now run Get-Command -Module MicrosoftTeams to list the available cmdlets.

Manage Microsoft Teams Admin Windows PowerShell

New Team PowerShell Options

For this example, we will create a new Team.  If we look at the results of a Get-Help New-Team -Full, you can see the syntax of the command as well as the parameters.

Create the Team

We can create a new team.

New-Team -DisplayName “UK Finance Team” -AccessType Private -Description “This Team is for UK Finance”

PowerShell Admin Command to Manage Microsoft Teams

This will provide us with the GroupID for the Team so we know the cmdlet was successful.  The Team is created, but it does not have membership, channels, or settings.

Add Members and Channels

To do this we can run Add-TeamUser, New-TeamChannel and a host of Set-Team other settings that aren’t covered here, but you can find more details of these in the Microsoft documentation.

Add-TeamUser -GroupId 4a07317c-c860-47db-9a85-00113764d528 -User user@domain.onmicrosoft.com
New-TeamChannel -GroupId 4a07317c-c860-47db-9a85-00113764d528 -DisplayName “Regulatory Compliance”



Id DisplayName Description


-- ----------- -----------
19:77e332ebe56c494181372e509b44251c@thread.skype Regulatory Compliance


A member has been added to the Team, and a new channel has been created.  You will notice that the channel has an ID associated with it that will be needed for the management of that channel.

Modify Settings

I mentioned I would not cover all the settings cmdlets, but I will briefly cover the TeamMemberSettings as an example because I want my users to create channels but not delete them, and I also do not want them to add/remove Apps.  I can run Set-TeamMemberSettings to do this.

Set-TeamMemberSettings -GroupId 4a07317c-c860-47db-9a85-00113764d528 -AllowCreateUpdateChannels true -AllowDeleteChannels false -AllowAddRemoveApps false


I now have my team created “mostly” as I would like but it has taken me a while and a lot of commands to do this.  Let me delete the team.

Remove the Team

Remove-Team -GroupId 4a07317c-c860-47db-9a85-00113764d528

Scripting the Team Creation

Now I can script the entire thing like this with the groupid captured from the initial creation.

$group = New-Team -DisplayName “UK Finance Team” -AccessType Private -Description “This Team is for UK Finance”
Add-TeamUser -GroupId $group.GroupId -User “user@domain.onmicrosoft.com”
New-TeamChannel -GroupId $group.GroupId -DisplayName “Regulatory Compliance”
Set-TeamMemberSettings -GroupId $group.GroupId -AllowCreateUpdateChannels true -AllowDeleteChannels false -AllowAddRemoveApps false

That is a bit more straightforward, but it could still be easier.  Microsoft has impeded a beta feature, for now, to easily create a team based on a template.