This guide demonstrates how to use the Get-MgTeam cmdlet in Microsoft Graph PowerShell to retrieve Microsoft Teams information. Learn how to list all teams, filter specific teams, and fetch detailed team properties with practical examples.
The Get-MgTeam cmdlet is part of the Microsoft Graph PowerShell module and is used to retrieve information about Microsoft Teams within an organization. This cmdlet is particularly useful for administrators who need to manage and monitor their Microsoft Teams environments.
Install-Module Microsoft.Graph -Scope CurrentUser.Connect-MgGraph -Scopes "Group.ReadWrite.All".Get-MgTeam [-TeamId <String>] [-All] [-Filter <String>] [-Search <String>] [-Property <String[]>] [<CommonParameters>]
Get-MgTeam -All
This command retrieves all Teams in the organization.
Get-MgTeam -TeamId "team-id"
Replace "team-id" with the actual ID of the Team you want to retrieve.
Get-MgTeam -Filter "displayName eq 'MSFT'"
This command retrieves Teams with the display name "MSFT".
Get-MgTeam -All -Property "id", "displayName"
This command retrieves only the ID, display name, and description properties of all Teams.
$teams = Get-MgTeam -All -Property "displayName", "description"
$teams | ForEach-Object {
"Team Name: $($_.displayName) Description: $($_.description)"
}
This script fetches all the Teams within the tenant, loops through them, and displays the team name and description.
$teams = Get-MgTeam -All | Where-Object { $_.displayName -like '*Sales*' }
$teams | ForEach-Object {
"Team ID: $($_.Id) Team Name: $($_.displayName)"
}
This script fetches all the Teams that contain ‘Sales’ in the display name, loops through them, and displays their team ID and name.
Get-MgTeam : Authorization_RequestDenied
Ensure you have the necessary permissions to execute this cmdlet. Typically, you need to be a Teams administrator or have the required delegated permissions.
Get-MgTeam : Resource 'team-id' does not exist or one of its queried reference-property objects are not present.
Verify that the Team ID is correct and that the Team exists in your organization.
Get-MgTeam : Invalid filter clause
Ensure that your filter syntax adheres to the OData query standards. Refer to the Microsoft Graph documentation for valid filter options.
-All parameter to ensure you get a complete list.-Property parameter to specify which ones. This reduces the amount of data processed and can improve performance.Get-MgTeam is a Microsoft Graph PowerShell cmdlet used to retrieve information about Microsoft Teams, such as their IDs, display names, and properties.
Use the following command to list all teams:
Get-MgTeam -All
Use the -TeamId parameter to fetch details of a specific team:
Get-MgTeam -TeamId "<TeamId>"
You can filter teams after retrieval using Where-Object. Example:
$Teams = Get-MgTeam -All
$PrivateTeams = $Teams | Where-Object { $_.Visibility -eq "Private" }
Use this script to export team details like name, ID, and visibility:
$Teams = Get-MgTeam -All
$Teams | Select-Object DisplayName, Id, Visibility | Export-Csv -Path "C:\Path\To\Teams.csv" -NoTypeInformation
-ExpandProperty to Fetch Nested Team Settings-ExpandProperty parameter lets you retrieve deeper team settings (like MemberSettings, GuestSettings, or MessagingSettings) inline, without needing subsequent calls.
This is helpful when you need a complete snapshot of a Team in one go.
-Search and -Filter for Flexible Queries-Search for keyword lookups and -Filter for precise criteria (e.g., displayName eq 'HR Team') to narrow results.
This hybrid approach provides both broad matching and strict filtering in larger tenant environments.
The Get-MgTeam cmdlet is a powerful tool for Microsoft Teams administrators, enabling them to retrieve detailed information about Teams within their organization. By understanding its parameters and possible errors, you can effectively use this cmdlet to manage and monitor your Teams environment.
For more details and additional examples, refer to the official Get-MgTeam Microsoft documentation.
© m365corner.com. All Rights Reserved. Design by HTML Codex