August 22, 2022
|
4
min read
Software developer sitting at desk working on computer

Today, we’ll look at using the PowerShell New-Team Template to make it simple for your IT administrators to create Microsoft Teams channels that adhere to these straightforward best practices.

Microsoft Teams is emerging as the default means of communication within organizations that utilize M365. Users can

  • Chat
  • Share files
  • Collaborate

However, as Microsoft Teams usage has increased, so has the number of duplicate and unused channels. Which can quickly lead to an ongoing problem of “Teams sprawl” if common sense controls aren’t put in place to control

  • Who can create Teams
  • Who can own them

Install the Microsoft Teams PowerShell Module

To install the required cmdlets, run the following commands in a PowerShell session:

Install-Module -Name PowerShellGet -Force -AllowClobber

Install-Module -Name MicrosoftTeams -Force -AllowClobber

Log in to your Office 365 Tenant and Update the Teams Module

Connect-MicrosoftTeams

Update-Module MicrosoftTeams

Listing of Existing Teams Templates

Before you set off to create new templates for teams, you will probably want to first see if the existing templates will satisfy your specific needs.

To see a list of all currently available templates, run the following in PowerShell:

Get-CsTeamTemplateList

This will return one of the two following objects:

  • Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.IErrorObject
  • Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.ITeamTemplateSummary

In the event of a successful call, the ITeamTemplateSummary will include an OdataId, along with the template’s name, a short description, and the number of apps and channels associated with the template.

Creating a Single Microsoft Teams Instance with PowerShell

To create a new M365 Teams instance with the PowerShell New-Team Template, run the following:

New-Team -DisplayName "My New Team" -Visibility Private -Description "A New Private Team" -MailNickName "MyTeamsManager" -Owner "manager@example.com"

Creating a Custom Microsoft Teams Template

The Microsoft documentation recommends creating a custom template by copying, and updating an existing template, like so:

PS C:> $template = Get-CsTeamTemplate -OdataId '/api/teamtemplates/v1.0/com.microsoft.teams.template.AdoptOffice365/Public/en-US'

PS C:> $template.Category = $null

PS C:> $template.DisplayName = “My new template”

PS C:> $template.Channel +=

@{

displayName="My new channel";

id="random-alphanumeric-id";

isFavoriteByDefault=$false;

}

PS C:> New-CsTeamTemplate -Locale en-US -Body $template

Notice that we’ve stored an existing template in the $template variable, which we can then update by accessing and updating its various properties with dot notation. We then call the New-CsTeamTemplate cmdlet and pass our updated template as the -Body argument.

Creating a New Microsoft Teams Instance from a Template

To create a new M365 Teams instance from a template, you can use the New-Team cmdlet with a -Template argument, like so:

New-Team -Template <OdataId>

Updating an Existing Microsoft Teams Template

To update an existing M365 Teams template, we can simply get the template we want to update with the Get-CsTeamTemplate cmdlet, and store it locally like so:

$template = Get-CsTeamTemplate -OdataId <OdataID>

Once we have the template stored in the $template variable, we can access and update properties on the object like so:

$template.FunSetting.AllowCustomMeme = $true

$template.FunSetting.AllowGiphy = $true

$template.FunSetting.AllowStickersAndMeme = $true

After we’ve got the local object into the desired state, we can save our changes by using the Update-CsTeamTemplate cmdlet:

Update-CsTeamTemplate -OdataId <OdataId> -Body $template

For a complete listing of available properties that you can update, refer to the Microsoft documentation on the topic.

How CoreView Can Help

While PowerShell is a very powerful tool, there is a tendency when using it to write one-off scripts, perhaps like our examples above.

This is a quick method to create the desired resources, to be sure, but it isn’t as efficient as it could be because it is very likely that such scripts will not be shared within your organization effectively for continued use.

This means that there will inevitably be duplicated efforts across your IT department over time.

Thankfully, CoreView provides a simple way to store such scripts as custom actions within its automation workflow framework, so that once a script is written, it can be stored and shared across your organization very easily.

To learn more about CoreView’s wide range of built-in automation actions and to learn about how you can store your custom scripts as CoreView actions for easy access and reuse by your team, schedule your demo.

Get a personalized demo today

Created by M365 experts, for M365 experts.