Microsoft Teams: PowerShell Support

As an IT Professional, I am always looking for ways to automate tasks and make daily operations simple. When it comes to Microsoft Teams, being able to automate the creation of teams, channels, and settings within a team is critical to the success of Microsoft Teams within an organization. PowerShell support for Microsoft Teams allows you to do exactly that, and it gives me additional ideas to make the administration of Teams easier:

  • Automatically provision new teams, new channels within the team, add members and set options such as a picture, and member permissions.
  • Create a self-service tool that uses PowerShell on the back-end to make creating teams easy for end-users but with controls for IT. For example, a user browses to a website form to create a team. PowerShell can check for a team that has a duplicate name, to ensure users aren't creating teams with the same name. I see this as one simple example but is powerful when we start to think about governance we can provide to the business on Microsoft Teams.
  • If I need to add a large number of members to a team, using PowerShell I can add those members in bulk from a .csv
  • Standardize settings within each team that is created.
  • What's your idea for using PowerShell with Microsoft Teams? (Tell me in the comments below!)

In this blog I will take you through how to download, install and run the a few examples in the Microsoft Teams PowerShell module. At the time of this writing, the following cmdlets are available:

Install-Module MicrosoftTeams

At the prompt type Y and press Enter:

If you are prompted for untrusted repository, type A (for Yes to All) and press Enter. The module will install.

Once installed, we can now connect to Microsoft Teams. To connect type the following and press Enter:



At the Microsoft Teams PowerShell Cmdlets dialog box, type your Office 365 credentials and press Enter

Once connected to the Microsoft Teams instance in your Office 365 tenant, the following will be displayed:

You can now start to run cmdlets, or scripts against Microsoft Teams! Note, at any time you can type Get-Command -Module MicrosoftTeams to see a full list of commands available:

To return a list of the teams in the environment, type the following and press Enter:


 Note: Within PowerShell, teams are referenced as a GroupID for the underlying Office 365 Group.

For the next example, let's create a new team for marketing employees in San Diego that is a private team. Type the following command and press Enter:

New-Team -DisplayName "San Diego Marketing" -AccessType Private

 The team will be created with an Office 365 GroupID assigned:

Note: The GroupID is important when you wish to assign classification policies to the underlying Office 365 group, in addition to when you need to remove the team among other things.

Within the Microsoft Teams client ( we can see the team has been created:

To remove the team, type the following and press Enter. Where <GroupID> is the GroupID of the team you created:

Remove-Team -GroupID <GroupID>

Conclusion: These are some of the basic functions you can perform with the Microsoft Teams PowerShell Module. Over time I'll be adding additional scenarios with PowerShell – if there's one you are interested in leave me a comment and I would be happy to write about it! 

Comments (3)

  1. An-kun says:

    Wonderful. Simply wonderful. Thanks alot for this.

  2. BEAUDOIN says:

    Hi Matt, I’m pleased to see these modules for Teams. I’m admin of my tenant, I’m able to create a Teams without issues, but when I try the commande Get-Teams I got :
    Get-Team : Error occurred while executing
    Code: GeneralException
    Message: Failed to parse MS Graph backend response for request GetUserGroupsRequest. Request Url:$/$filter=groupTypes/any(c:c+eq+'Unified‘)&$top=999,
    Request Method: GET. The response is invalid, cannot convert to type IList`1Error converting value {null} to type
    ‘System.DateTime’. Path ‘value[0].renewedDateTime’, line 1, position 1871.
    RequestId: 77d68078-f5dd-482e-8c8f-d97065891fb6
    DateTimeStamp: 2017-11-08T10:48:49
    HttpStatusCode: GeneralException
    Au caractère Ligne:1 : 1
    + Get-Team
    + ~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Get-Team], ApiException
    + FullyQualifiedErrorId : Microsoft.TeamsCmdlets.PowerShell.Custom.ErrorHandling.ApiException,Microsoft.TeamsCmdle

    Any ideas ?


Skip to main content