Skip to content

Get-MSTTeamChannelUser-Html

Teams: HTML report of users of a channel

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$GroupId,
    [Parameter(Mandatory = $true)]
    [string]$DisplayName,
    [ValidateSet('Member','Owner','Guest')]
    [string]$Role
)

Process {
    try {
        [hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'; 'GroupId' = $GroupId; 'DisplayName' = $DisplayName}
        if (-not [System.String]::IsNullOrWhiteSpace($Role)) {
            $cmdArgs.Add('Role', $Role)
        }

        $result = Get-TeamChannelUser @cmdArgs | Sort-Object Name | Select-Object Name, User, Role, UserID

        if ($null -eq $result -or $result.Count -eq 0) {
            Write-Output "No channel users found"
            return
        }

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

GroupId of the parent team

Display name of the private channel

Filter results to only users with the given role

An interactive directory of PowerShell scripts.