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!)

UPDATE: 12/2/2018: PowerShell module updated to 0.9.6 now allows admins to manage any team, even when they are not the team owner.

UPDATE 12/28/2017: Documentation on GitHub

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 (32)
  1. An-kun says:

    Wonderful. Simply wonderful. Thanks alot for this.

    1. An-kun says:

      Ok. I was too quick. Neither of the cmdlets seem to work for me at least, and it requires an assigned Teams license on my admin account.. (After which it still dosnt work.)
      Still nice to see that the admin support for Teams is being improved.

  2. Paul Maher says:

    Hi, great to see these API’s are available. One thing we would like to do, as part of the teams housekeeping, is identify Teams that no longer appear to be in use and disable them. Is there a way to achieve this automatically using these Powershell APIs?

  3. 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 ?


    1. John says:

      Type in Connect-Microsoftteams

    2. Brownst says:

      I have the same problem, Beaudoin. It’s impossible use with this error.

  4. When similar functionality will be available in Microsoft Graph? —

  5. Thanks for publishing this! I was waiting for this so I can start creating TEAMS programmatically. I would like to go a little bit further and have the ability using powershell of removing the Wiki link on the TAB and adding custom Web ones. Could I accomplish that today?

  6. Jonas Björkander says:

    I have problem with the get-team command also. All I get is the result of 1 (one) team – but I have alot of them provisioned already (most of them are upgraded from o365 groups but there are more than one provisioned from within the teams client). No errors, just one result.

  7. Cecilie says:

    Hi, would it be possible to use these cmdlets to create some functionality for archiving channels and chats do you think? While we’re waiting for Microsoft to provide the functionality 🙂

  8. Giuseppe says:

    Hi Matt, can be possible to add function to manage the Tabs ?

  9. Thomas Glaser says:

    > “Note, at any time you can type Get-Command -Module MicrosoftTeams to see a full list of commands available”

    Seems that Get-TeamHelp does exactly that. Pointless function IMO, but it’s there and might be easier to remember for some people.

    1. Matt Soseman says:

      Yes, you are correct, that is an alternative way.

  10. Coleman says:

    Hi I am so thrilled I found your web site, I really found you by mistake, while I was searching on Aol for something else, Anyhow I am here now and would just like to say thank you for a tremendous post and a all round exciting blog (I also love the theme/design), I donít have time to read through it all at the moment but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read more, Please do keep up the excellent work.

  11. Henry says:

    Hi Matt,

    Nice blog. Is there a powershell command to create template folders, add files to the Files tab and to add a new tab or delete the Wiki tab? We’re thinking of automating the process of MS Team creation where we populate the team with template files and folders before giving it to its respective team owner/members.

  12. Claudia says:

    Nice post! So helpful 🙂

    When it comes to use the command “Get-Teams” it only shows the Teams you are a member of, right? If you have a Global Admin role, is there way (or could it be a way in a future version) that you could list all the created Teams in the tenant? That way, as admins we could check how many Teams we have.

    Thanks a lot!

  13. Vish86 says:


    Good article … When we create a team with powershell, why it does not trigger a email to members? Members do get email notification when teams are created manually.


  14. Bjorn says:

    Any plans for a cmdlet to get/set the Channels a User has favorited or followed? An essential part of Teams adoption is getting Users into conversations via the appropriate favorited Channels. Ideally we could set favorite Channels for Users to get them going. The ‘first 5’ Channel favorite feature is arbitrary and creates unnecessary admin work.

  15. Manish says:

    Hi Matt, thanks for your post.
    I am relatively new to this. Excuse me if my question is lame.
    I am trying to connect to powershell on windows 7. When I type command Install-Module MicrosoftTeams, I get error as “Install-Module is not recognized as….”
    Could you please help me with this?

  16. Hi,
    Is there any varible that holds information about Teams connection.
    If you use Connect-MicrosoftTeams it returns information, but if you don’t save it in soma var can you get those information back.
    Get-PSSession dosen’t returns any about Teams connection.

  17. Hi.
    I connect to Teams by PowerShell with GlobalAdmin account.

    Global Admin can’t receive all list team group.

    PS E:\> Get-Team
    Get-Team : Error occurred while executing
    Code: AccessDenied
    Message: Admin Login. Teams is disabled in user licenses
    RequestId: 2
    DateTimeStamp: 2018-08-21T16:50:59
    HttpStatusCode: AccessDenied
    At line:1 char:1
    + Get-Team
    + ~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Get-Team], ApiException
    + FullyQualifiedErrorId : Microsoft.TeamsCmdlets.PowerShell.Custom.ErrorHandling.ApiException,Microsoft.TeamsCmdlets.PowerShell.Custom.GetTeam

    1. Kazzan says:

      Similar with change of Team property like Picture. Be a Global Admin is not enough.

  18. Thanks for the post.
    How can I subscribe to event of New Team Created, and than add a specific User to this Team?

  19. T. Kujala says:

    Great work. I was looking for tips managing teams via PowerShell and then I found your blog. Thank you!

  20. B Bergman says:

    SUPER awesome – thank you so much! Just what we needed.

  21. Thank you for creating this. Are there any plans to add channel email addresses to the output of Get-TeamChannel? I would also like to see a ‘Creator’ field for Get-Team or Get-TeamUser to help determine who originally created a Team if additional users are elevated to owner status after the fact. Hit me up internally at alias ‘brianday’ if it’s easier to communicate.

  22. Hello
    Great blog, very helpful, thank you.
    I’ve been working with scripts and have managed to get quite a bit working. I am struggling to find the cmdlet and how to auto-favourite a channel to the whole team. I can see how to do this in the teams user interface but can’t find out how to do it via powershell scripts. Can anyone please help me.
    Thank you

  23. Great Post !!!
    Is there any way to get the files which are added in the channels or options to get upload ?

  24. Asad Ali PK says:

    This is a great post. Now I want to upload files to a TeamChannel. I dont see any cmdlet that suggests that I can do that (couldnt find anything on Technet either). I realize that I may be able to do it via Sharepoint (because I can get a Sharepoint link when I navigate to the Team-Channel files tab and click on Get Link and hit the Sharepoint tab on the pop-up). Any ideas on how to go about it? I am not an Admin on Office 365. Thanks,


Comments are closed.

Skip to main content