Skip to content

New-MgmtGraphTeamChannel

MgmtGraph: Provisions a new Microsoft Team channel

#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Teams

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true, Position = 0)]
    [string]$Identity,

    [Parameter(Mandatory = $true)]
    [string]$DisplayName,

    [string]$Description,

    [switch]$FavoriteByDefault
)

Process {
    try {
        $params = @{
            'TeamId'      = $Identity
            'DisplayName' = $DisplayName
            'Confirm'     = $false
            'ErrorAction' = 'Stop'
        }

        if ($Description) { $params.Add('Description', $Description) }
        if ($FavoriteByDefault) { $params.Add('IsFavoriteByDefault', $true) }

        $channel = New-MgTeamChannel @params
        
        $result = [PSCustomObject]@{
            TeamId      = $Identity
            DisplayName = $DisplayName
            Id          = $channel.Id
            Status      = "ChannelCreated"
            Timestamp   = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the ID of the Team where the channel will be created.

Specifies the display name for the new channel.

Optional. Specifies a description for the channel.

Off

Optional. If set to $true, the channel will be automatically marked as favorite for all team members.

An interactive directory of PowerShell scripts.