Create a new Team in Microsoft Teams using PowerShell

In this post, I am going share Powershell commands to create a new team, add team (or enable team) in an existing Office 365 group and create a team from an existing SharePoint Online site. This post also includes commands to add members, owners, and channels in the newly created team. We can use the New-Team cmdlet from the Microsoft Teams Powershell module to add a team.

Before proceed run the below command to install Microsoft Teams Powershell module if you have not already installed.

Install-Module MicrosoftTeams -Force

Note: You have to run the powershell with “Run as administrator” privilege to install this module.

Once you have installed the Teams module, then run the following command to connect Microsoft Teams and it will ask your credentials to proceed.

Connect-MicrosoftTeams

Create a new team

Run the following command to create a new team.

New-Team -DisplayName "Test Team" -Visibility Public -Description "This is test Team"

While creating a team, this command also creates a new Office 365 Group with the same name and associate the new team with this group. On successfull run, this command returns the newly created Group object with GroupId property (which is TeamId), we can note this GroupId for future uses (ex: to add members, owners, and channels).

You can also provide more inputs with New-Team cmdlet, like MailNickName (Mail Alias for Office 365 Group), Owner (Additional owner). You can refer New-Team cmdlet documentation for more details.

New-Team -DisplayName "Test Team" -MailNickName "TestTeam" -Visibility Public -Description "This is test Team"

Create a team from existing Office 365 Group

If you already created and worked with an Office 365 Group, then you can easily convert this group to a team using the New-Team command by just passing the id of the group.

New-Team -GroupId "Existing Group ID - GUID"

Here, you cannot provide the group related values that are already specified in the existing group, ex: Visibility, Alias, Description, or DisplayName.

Create a team from existing SharePoint Online Site

You may have a scenario to enable Office 365 Group (Groupify) and add Team (Teamify) with existing SharePoint Online Site. If you have already connected the site with Office 365 group, then you can easily Teamify the group using the above command. If you yet to integrate the site with Office 365 group, then first you need to run the Set-SPOSiteOffice365Group cmdlet to add a new Office 365 group with the site and you can enable teams feature in the newly created group.

Before proceed run the below command to install the SharePoint Online Powershell module if you have not already installed.

Install-Module -Name Microsoft.Online.SharePoint.PowerShell

The below commands connect the site “TestSite1” with the new group “TestGroup” and teamify the new group.

#Connect SharePoint Service
$Cred = Get-Credential
Connect-SPOService -Url "https://YourTenantName-admin.sharepoint.com " -Credential $Cred
#Groupify - Connect the Site to new Office 365 Group
$SiteURL = "https://YourTenantName.sharepoint.com/sites/TestSite1"
$GroupName = "TestGroup"
$MailNickName = "TestGroup"
Set-SPOSiteOffice365Group -Site $SiteURL -DisplayName $GroupName -Alias $MailNickName
#Teamify - Create Team from the Site Associated O365 Group
$SiteObj = Get-SPOSite -Identity $SiteURL
New-Team -GroupId $SiteObj.GroupId.Guid

Add Members and Owners

We can use the Add-TeamUser cmdlet to add a user as member or owner in an existing team. The below command adds the user “[email protected]” to a team with the id “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”.

Add-TeamUser -GroupId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -User "[email protected]"

We have to set the parameter Role as Owner to add a user as owner.

Add-TeamUser -GroupId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -User "[email protected]" -Role Owner

Add New Channels

We can use the New-TeamChannel cmdlet to create a new channel in a team. The below command creates a standard channel with display name as “Support”

New-TeamChannel -GroupId "<GroupId>" -DisplayName "Support"

You can create a private channel by passing the parameter MembershipType as Private.

New-TeamChannel -GroupId "<GroupId>" -DisplayName "Support" -MembershipType Private

Modify Team, Channel and Member Settings

We can use the Set-Team cmdlet to update the properties of a team, including its displayname, description, and team-specific settings.

Set-Team -GroupId "<GroupId>" -DisplayName "Edit Test Team" -Visibility Public

You can refer Set-TeamChannel and Set-TeamMemberSettings commands to update channel and member settings.


Advertisement

1 thought on “Create a new Team in Microsoft Teams using PowerShell”

Leave a Comment