PowerShell Genie

Teams inventory

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Use Get-Team to report team names, Microsoft 365 group IDs, visibility, and archived status in a PowerShell inventory.

The script

1PS> Get-Team | Select-Object GroupId,DisplayName,Visibility,Archived

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output
    1 GroupId DisplayName Visibility Archived
    2 ------- ----------- ---------- --------
    3 11111111-2222-3333-4444-555555555555 Sample object Private False
    Inspect this example’s structure

    Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

    Get-Team | Select-Object GroupId,DisplayName,Visibility,Archived
    1. Stage 1Get-TeamPositional values or no named parameters
    2. Stage 2Select-ObjectPositional values or no named parameters

      How it works

      Get-Team returns each team with the GroupId that links it back to its underlying Microsoft 365 group, the display name, the Visibility setting separating public from private, and the Archived flag.

      Adapting it

      Join on GroupId against Get-MgGroup output to bring in creation dates and owners, which are the fields a lifecycle review needs and this cmdlet does not provide.

      Requirements

      MicrosoftTeams module with Connect-MicrosoftTeams, plus a Teams administrator role for full visibility.

      If the result is unexpected

      A Teams inventory excludes a team visible to another user.

      Tenant context and the signed-in identity's permitted view can differ.

      1. Confirm the Teams connection and query a known team by its identifier under the intended account.

      Validate the result

      The known team is present or the access limitation is explicitly documented.

      Keep the check reliable

      Record the account context and avoid treating a restricted view as a tenant-wide count.

      Primary documentation

      PowerShell objects and pipelines documentation

      Continue
      Genie guideTeams inventory

      Use Get-Team to report team names, Microsoft 365 group IDs, visibility, and archived status in a PowerShell inventory.