Skip to content

Get-MgmtGraphTeam

MgmtGraph: Audits Microsoft Teams

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

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

Process {
    try {
        $params = @{
            'ErrorAction' = 'Stop'
        }

        if ($Identity) {
            $params.Add('TeamId', $Identity)
            $teams = Get-MgTeam @params
        }
        else {
            $params.Add('All', $true)
            $teams = Get-MgTeam @params
        }

        $results = foreach ($t in $teams) {
            [PSCustomObject]@{
                DisplayName     = $t.DisplayName
                Id              = $t.Id
                Description     = $t.Description
                Visibility      = $t.Visibility
                IsArchived      = $t.IsArchived
                CreatedDateTime = $t.CreatedDateTime
                Timestamp       = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
            }
        }

        Write-Output ($results | Sort-Object DisplayName)
    }
    catch {
        throw
    }
}

Optional. Specifies the ID of the Team to retrieve. If omitted, all Teams are listed.

An interactive directory of PowerShell scripts.