If you're looking to query and manage Microsoft Teams using Graph PowerShell, you may instinctively reach for the Get-MgTeam cmdlet. But you can also use Get-MgGroup – because, well, Microsoft Teams are actually Microsoft Groups with the value "Team" in their resourceProvisioningOptions property.
In this article, you’ll learn how to search Microsoft Teams using Get-MgGroup, explore practical examples, and troubleshoot common issues.
Get-MgGroup -Filter "<OData filter expression>" -All -ConsistencyLevel eventual
🔹 Microsoft Teams are actually Microsoft 365 Groups with the value "Team" in their resourceProvisioningOptions property.
🔹 Use the OData any() function to query this property.
Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')" -All -ConsistencyLevel eventual
This command lists all Microsoft Teams, including both public and private ones.
Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team') and displayName eq 'Marketing Team'" -All -ConsistencyLevel eventual
This retrieves the Team named exactly "Marketing Team".
Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')" -All -ConsistencyLevel eventual |
Where-Object { $_.Visibility -eq "Private" }
Filters the list of Teams locally to show only those with visibility set to Private.
Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')" -All -ConsistencyLevel eventual |
Where-Object { $_.Visibility -eq "Public" }
Filters for Teams with visibility set to Public.
Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')" -All -ConsistencyLevel eventual |
Where-Object { $_.DisplayName -like "*Project*" }
Since the -Filter parameter only supports exact matching, this example retrieves all Teams first, then filters locally (client-side) to match names containing "Project".
Error | Cause | Fix |
Error: Property 'visibility' does not support filtering | You're trying to use visibility in the -Filter clause, which is not allowed. | Perform client-side filtering instead using Where-Object in PowerShell after retrieving the data. |
Error: Access Denied or Authorization_RequestDenied | Insufficient Graph API permissions. | Use one of the following scopes when signing in: Connect-MgGraph -Scopes "Group.Read.All", "Directory.Read.All" |
Although the Get-MgTeam cmdlet does support direct filtering or searching, you can still effectively retrieve and manage Microsoft Teams by using Get-MgGroup and filtering on the resourceProvisioningOptions property. With the right query structure and parameters, you can fetch Teams based on name, visibility, and other metadata — ensuring robust and efficient administration of your Teams environment.
Use these examples as templates to build powerful automation scripts for reporting, auditing, and bulk management of Microsoft Teams.
© m365corner.com. All Rights Reserved. Design by HTML Codex