All scripts
Microsoft 365 215

Get-TeamsChannelInventory

Exports every team and its channels, including private and shared channels, to a single CSV so you can see the real channel sprawl across the tenant in one place.

Get-TeamsChannelInventory.ps1
<#
.SYNOPSIS
    Exports every team and its channels to a single inventory.

.DESCRIPTION
    Lists all teams in the tenant, then enumerates the standard, private
    and shared channels for each one, so channel sprawl across the whole
    tenant is visible in one export instead of clicking through team by
    team.

.PARAMETER ExportPath
    Path to write the CSV to. Defaults to the current directory.

.EXAMPLE
    .\Get-TeamsChannelInventory.ps1

.NOTES
    Requires the MicrosoftTeams module and an active Connect-MicrosoftTeams session.

.AUTHOR
    Shehryar Hassan
#>

param(
    [string]$ExportPath = (Get-Location).Path
)

$teams = Get-Team
$rows = foreach ($team in $teams) {
    $channels = Get-TeamChannel -GroupId $team.GroupId
    foreach ($channel in $channels) {
        [pscustomobject]@{
            TeamName    = $team.DisplayName
            ChannelName = $channel.DisplayName
            ChannelType = $channel.MembershipType
        }
    }
}

$file = Join-Path $ExportPath "teams-channel-inventory_$(Get-Date -Format yyyyMMdd_HHmmss).csv"
$rows | Export-Csv -Path $file -NoTypeInformation
Write-Host "Exported $($rows.Count) channels across $($teams.Count) teams to $file" -ForegroundColor Cyan

Read it before you run it, and test in a safe tenant first.