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/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:
For demonstration purposes of my blog I am going to allow PowerShell to automatically download and install the module from the PowerShell Gallery. Let's step through that together:
First, launch PowerShell as an administrator by typing PowerShell in the start menu then right click Windows PowerShell and select Run as administrator. At the UAC prompt click Yes.
Next, within PowerShell type the following and press Enter:
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 (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!