Skip to content

Get-MSTTeamChannels-Html

Teams: HTML report of channels for all teams

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [string]$Channel
)

Process {
    try {
        [hashtable]$getArgs = @{'ErrorAction' = 'Stop'}
        $teams = Get-Team @getArgs | Sort-Object DisplayName
        $result = @()

        foreach ($team in $teams) {
            Get-TeamChannel -GroupId $team.GroupId -ErrorAction Stop | Sort-Object DisplayName | ForEach-Object {
                if ((-not $PSBoundParameters.ContainsKey('Channel')) -or ($_.DisplayName -like "*$($Channel)*")) {
                    $result += [PSCustomObject]@{
                        Team            = $team.DisplayName
                        Channel         = $_.DisplayName
                        Description     = $_.Description
                        ChannelType     = $_.MembershipType
                    }
                }
            }
        }

        if ($result.Count -eq 0) {
            Write-Output "No channels found"
            return
        }

        Write-Output ($result | ConvertTo-Html -Fragment)
    }
    catch { throw }
}

Specify a channel name to filter (supports wildcard matching)

An interactive directory of PowerShell scripts.