Skip to content

Remove-MSTTeamChannel

Teams: Delete a channel from a team

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$GroupId,
    [Parameter(Mandatory = $true)]
    [ValidateLength(5, 50)]
    [string]$DisplayName
)

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

        $null = Remove-TeamChannel @cmdArgs

        [PSCustomObject]@{
            Timestamp   = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
            GroupId     = $GroupId
            DisplayName = $DisplayName
            Status      = "Team channel '$DisplayName' successfully removed"
        }
    }
    catch { throw }
}

GroupId of the team

Channel display name to remove

An interactive directory of PowerShell scripts.