Wednesday, 4 August 2021

Microsoft Teams - Powershell Administration Commands

 Microsoft Teams has a powershell module available that allows you to perform just about all Teams management tasks using a script. This is very convenient for bulk operations, like creating lots of teams and keeping team memberships up to date - especially since the Teams web admin interface can be quite slow and cumbersome.

Here's a quick guide on some of the most common commands and uses

Install Microsoft Teams Powershell Module

Use the command below to install the Microsoft Teams powershell cmdlets

install-module -name MicrosoftTeams -force

Create a Team

I like to create new teams by using a variable ($newteam) - this makes additional tasks easier since you can reference the unique group ID for the new team directly from the $newteam variable.

$newteam = new-team -displayname "Test Team" -mailnickname "Test-Team" -owner "user@domain.com"

Update the properties for the display name, mailnickname (can't have spaces) and the team owner

Add a User/Member to a Team

If you've created the team like I have above and used a variable like $newteam, you can then use the properties for this variable for other tasks like this

add-teamuser -groupid $newteam.groupid -user "user@domain.com"

Add an additional Owner to a Team

add-teamuser -groupid $newteam.groupid -user "user@domain.com" -role owner

Remove User/Member from a Team

remove-teamuser -groupid $newteam.groupid -user "user@domain.com"


No comments:

Post a Comment