Share via


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 https://github.com/MicrosoftDocs/office-docs-powershell/tree/master/teams/teams-ps/teams

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:

Connect-MicrosoftTeams

 

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:

Get-Team

 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 (teams.microsoft.com) 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

  • Anonymous
    November 07, 2017
    Wonderful. Simply wonderful. Thanks alot for this.
    • Anonymous
      November 08, 2017
      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.
  • Anonymous
    November 08, 2017
    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?
  • Anonymous
    November 08, 2017
    The comment has been removed
    • Anonymous
      November 08, 2017
      Type in Connect-Microsoftteams
    • Anonymous
      December 21, 2017
      I have the same problem, Beaudoin. It's impossible use with this error.
  • Anonymous
    November 08, 2017
    good one
  • Anonymous
    November 08, 2017
    When similar functionality will be available in Microsoft Graph? --
  • Anonymous
    November 15, 2017
    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?
  • Anonymous
    November 15, 2017
    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.
  • Anonymous
    November 21, 2017
    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 :-)
  • Anonymous
    November 22, 2017
    Hi Matt, can be possible to add function to manage the Tabs ?
  • Anonymous
    November 27, 2017
    > "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.
    • Anonymous
      November 27, 2017
      Yes, you are correct, that is an alternative way.
  • Anonymous
    December 02, 2017
    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.
  • Anonymous
    December 04, 2017
    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.
  • Anonymous
    December 05, 2017
    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!
  • Anonymous
    December 06, 2017
    Hi,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.ThanksVishwa
  • Anonymous
    December 12, 2017
    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.
  • Anonymous
    January 10, 2018
    The comment has been removed
  • Anonymous
    January 29, 2018
    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.
  • Anonymous
    August 21, 2018
    The comment has been removed
    • Anonymous
      November 09, 2018
      Similar with change of Team property like Picture. Be a Global Admin is not enough.
  • Anonymous
    November 18, 2018
    Thanks for the post.How can I subscribe to event of New Team Created, and than add a specific User to this Team?
  • Anonymous
    November 25, 2018
    Great work. I was looking for tips managing teams via PowerShell and then I found your blog. Thank you!
  • Anonymous
    January 10, 2019
    SUPER awesome - thank you so much! Just what we needed.
  • Anonymous
    January 17, 2019
    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.
  • Anonymous
    February 10, 2019
    HelloGreat 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
  • Anonymous
    February 11, 2019
    Great Post !!!Is there any way to get the files which are added in the channels or options to get upload ?
  • Anonymous
    March 05, 2019
    very helpful.
  • Anonymous
    May 30, 2019
    Hi,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,Asad