Skip to content

Update-MSTTeamTemplate

Teams: Update a custom team template

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true, ParameterSetName = 'ById')]
    [string]$ODataId,
    [Parameter(Mandatory = $true, ParameterSetName = 'ByName')]
    [string]$Name,
    [string]$ShortDescription,
    [string]$Description,
    [string]$Categories,
    [bool]$DiscoverySettingShowInTeamsSearchAndSuggestion,
    [string]$Icon
)

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

        if ($PSCmdlet.ParameterSetName -eq 'ByName') {
            $template = (Get-CsTeamTemplateList -ErrorAction Stop) | Where-Object Name -eq $Name | Select-Object -First 1
            if ($null -ne $template) { $cmdArgs.Add('ODataId', $template.OdataId) }
        }
        else {
            $cmdArgs.Add('ODataId', $ODataId)
        }

        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 = Update-CsTeamTemplate @cmdArgs | Select-Object *

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

Composite URI of the template

Name of the template to update

Template short description

The template description

List of categories

If teams are visible in search and suggestions

File path to icon image

An interactive directory of PowerShell scripts.