Skip to content

Get-MSTTeam-Html

Teams: HTML report of teams

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [string]$GroupId,
    [bool]$Archived,
    [string]$DisplayName,
    [string]$MailNickName,
    [ValidateSet('Public','Private')]
    [string]$Visibility,
    [ValidateSet('*','GroupId','DisplayName','Description','Visibility','MailNickName','Archived')]
    [string[]]$Properties = @('GroupId','DisplayName','Description','Visibility','MailNickName','Archived')
)

Process {
    try {
        if ($Properties -contains '*') {
            $Properties = @('*')
        }
        [hashtable]$getArgs = @{'ErrorAction' = 'Stop'; 'Archived' = $Archived}

        if (-not [System.String]::IsNullOrWhiteSpace($GroupId)) { $getArgs.Add('GroupId', $GroupId) }
        if (-not [System.String]::IsNullOrWhiteSpace($DisplayName)) { $getArgs.Add('DisplayName', $DisplayName) }
        if (-not [System.String]::IsNullOrWhiteSpace($MailNickName)) { $getArgs.Add('MailNickName', $MailNickName) }
        if (-not [System.String]::IsNullOrWhiteSpace($Visibility)) { $getArgs.Add('Visibility', $Visibility) }

        $result = Get-Team @getArgs | Sort-Object DisplayName | Select-Object $Properties

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

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

Specify the GroupId of a specific team

Filters to return teams that have been archived or not

Filters to return teams with a full match to the provided display name

Specify the mail nickname of the team

Filters to return teams with a specific visibility value

List of properties to expand. Use * for all properties

An interactive directory of PowerShell scripts.