Microsoft 365

MS-Teams: Create and configure Teams with PowerShell

What is one of the most used tools these days? It is – by all means – MS-Teams. In this blog post I will show you how to connect to MS-Teams and how to create a Team with PowerShell. I will also do some other stuff, too. Let’s jump in.

Install the MS-Teams Module

First we need to install a PowerShell module called Microsoft Teams.

Install-Module MicrosoftTeams

Now let’s connect to MS-Teams

Connect-MicrosoftTeams

Finally let’s check if the newly imported MS-Teams commands are present.

Get-Command -Module MicrosoftTeams

That looks good.

Retrieve all Teams

Get-Team is the cmdlet we need to use when we want to list all teams.

Get-Team

To list only one team run Get-Team with the -GroupId parameter or use a filter to filter out the group based on the displayname.

Get-Team -GroupId 4d530d96-c1b6-4e64-9386-93b050c40e7e

Get-Team | Where-Object DisplayName -like '*sid-500*'

Create a Team

New-Team is the command we need if you we want to create a new team.

New-Team -DisplayName TestTeam -Owner f.huber@sid-500.com -Visibility Public

Create multiple Teams at once

If you know me, then you know what comes next. Automation. The command below creates Team1 – Team 5.

1..5 | ForEach-Object -Process {New-Team -DisplayName Team$_}

Cool stuff.

Add Team Members

You now might wonder whether we have skipped something. You are right. We need to add team members.

In order to do this we need to retrieve the teams group id.

Get-Team | Select-Object -Property DisplayName,GroupId

Now that we have discovered the Groupid, we are able to add team members.

Add-TeamUser -GroupId 665e8b48-1b62-4c7a-95fa-4517135bd95c -User 'f.huber@sid-500.com'

Fine. That’s it for today. See you next time with Teams.

7 replies »

  1. Obwohl ich mich mit dieser Thematik nicht so gut auskenne, wie vermutlich andere Leuten die eurem Blog hier verfolgen wurde ich euch nur kurz loben und sagen das Sie weiter so machen. Das kann man auch hier an Kommentaren sehen. Viele Leute bedanken sich und geben euch eine große Unterstützung.

    Liked by 1 person

  2. Patrick, thank you for the post, it helps me to get started! When I run the command get-team, PS sort of enters a never ending job. It doesn’t return any teams.
    I work from a Mac, using Visual Studio Code, PowerShell 7.1. That module should work cross-platform.
    The Connect-Team works, so I get connected to a tenant.
    Do you have any idea what is wrong?

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.