Tuesday, 10 August 2021

Microsoft Teams - Get Team ID/Group ID using Powershell

Many Microsoft Teams commands for powershell require you to specify the group id for a team so the script knows which one of your teams you wish to work on. The Group ID/Team ID is a unique string of letters and numbers which is why it's commonly used to ensure only one team would ever be targeted by a command.

Use the command(s) below to get the group id for one, or all of your teams.

Connect-MicrosoftTeams

get-team -displayname "Test Class"

You should get a response with the GroupID shown like in the example below;


Simple, right? What if I wanted to get the properties for all of my teams? Try the command below

get-team

You can even store the groupid in a variable so it's easier to reference in subsequent commands. In this example, we'll store the properties in the $teamprops variable;

$teamprops = get-team -displayname "Test Class"

You can then use the $teamprops.groupid property in another command - for example;

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

No comments:

Post a Comment