Query Microsoft Teams Using Microsoft Graph PowerShell

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.


Cmdlet Syntax

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.


Usage Examples

  1. Find All Microsoft Teams in the Tenant
  2. Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')" -All -ConsistencyLevel eventual

    This command lists all Microsoft Teams, including both public and private ones.

  3. Search for a Team by Display Name (Exact Match)
  4. 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".

  5. Get All Private Teams (Client-Side Filtering)
  6. 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.

  7. Get All Public Teams (Client-Side Filtering)
  8. 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.

  9. Search Teams by Partial Name (Client-Side Filter)
  10. 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".


Important Considerations

  • Always use -All with -ConsistencyLevel eventual when filtering group data.
  • You must use resourceProvisioningOptions/Any(x:x eq 'Team') to isolate Microsoft Teams from other Microsoft 365 Groups.
  • The -Filter parameter supports only OData expressions — it does not support wildcards or partial text matching natively.
  • Properties like visibility are not filterable through the Microsoft Graph API — use client-side filtering instead.
  • Ensure you’re signed in with permissions like Group.Read.All or Directory.Read.All.

Common Errors & Fixes

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"

Conclusion

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.


Graph PowerShell Explorer Widget

20 Graph PowerShell cmdlets with easily accessible "working" examples.


Permission Required

Example:


                


                


                

© m365corner.com. All Rights Reserved. Design by HTML Codex