Skip to content

Remove-MSTTeamTemplate

Teams: Delete a Team Template

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true, ParameterSetName = 'ById')]
    [string]$ODataId,
    [Parameter(Mandatory = $true, ParameterSetName = 'ByName')]
    [string]$Name
)

Process {
    try {
        if ($PSCmdlet.ParameterSetName -eq 'ById') {
            $null = Remove-CsTeamTemplate -OdataId $ODataId -ErrorAction Stop
            $templateId = $ODataId
        }
        else {
            $null = (Get-CsTeamTemplateList -ErrorAction Stop) | Where-Object Name -eq $Name | ForEach-Object { Remove-CsTeamTemplate -OdataId $_.OdataId -ErrorAction Stop }
            $templateId = $Name
        }

        [PSCustomObject]@{
            Timestamp  = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
            TemplateId = $templateId
            Status     = 'Team template successfully removed'
        }
    }
    catch { throw }
}

Composite URI of the template

Name of the template to delete

An interactive directory of PowerShell scripts.