Skip to content

Set-MSTTeamChannel

Teams: Update Team channel settings

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$GroupId,
    [Parameter(Mandatory = $true)]
    [ValidateLength(5, 50)]
    [string]$CurrentDisplayName,
    [ValidateLength(5, 50)]
    [string]$NewDisplayName,
    [ValidateLength(0, 1024)]
    [string]$Description
)

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

        if (-not [System.String]::IsNullOrWhiteSpace($Description)) {
            $cmdArgs.Add('Description', $Description)
        }
        if (-not [System.String]::IsNullOrWhiteSpace($NewDisplayName)) {
            $cmdArgs.Add('NewDisplayName', $NewDisplayName)
        }

        $result = Set-TeamChannel @cmdArgs | Select-Object *

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

GroupId of the team

Current channel name

New channel display name

Updated channel description

An interactive directory of PowerShell scripts.