Skip to content

New-MSTTeamTemplate

Teams: Create a new team template

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$DisplayName,
    [string]$Locale,
    [string]$ShortDescription,
    [string]$Description,
    [string]$Categories,
    [bool]$DiscoverySettingShowInTeamsSearchAndSuggestion,
    [string]$Icon
)

Process {
    try {
        [hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'; 'DisplayName' = $DisplayName}

        if (-not [System.String]::IsNullOrWhiteSpace($Locale)) { $cmdArgs.Add('Locale', $Locale) }
        if (-not [System.String]::IsNullOrWhiteSpace($ShortDescription)) { $cmdArgs.Add('ShortDescription', $ShortDescription) }
        if (-not [System.String]::IsNullOrWhiteSpace($Description)) { $cmdArgs.Add('Description', $Description) }
        if (-not [System.String]::IsNullOrWhiteSpace($Categories)) { $cmdArgs.Add('Categories', $Categories) }
        if ($PSBoundParameters.ContainsKey('DiscoverySettingShowInTeamsSearchAndSuggestion')) { $cmdArgs.Add('DiscoverySettingShowInTeamsSearchAndSuggestion', $DiscoverySettingShowInTeamsSearchAndSuggestion) }
        if (-not [System.String]::IsNullOrWhiteSpace($Icon)) { $cmdArgs.Add('Icon', $Icon) }

        $result = New-CsTeamTemplate @cmdArgs | Select-Object *

        if ($null -eq $result) {
            Write-Output "Team template created"
            return
        }
        $result | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format 'yyyy-MM-dd HH:mm:ss') -PassThru -Force
    }
    catch { throw }
}

Name of the template

The locale of the template

Template short description

The template description

List of categories

If teams created from this template are visible in search and suggestions

File path to icon image (.png, .gif, .jpg, or .jpeg)

An interactive directory of PowerShell scripts.