The Get-MgTeamMemberCount cmdlet in Microsoft Graph PowerShell enables administrators to retrieve the member count of a specified Microsoft Team. This cmdlet is particularly useful when you need an overview of team sizes across an organization, track membership changes over time, or monitor large teams for governance purposes.
Get-MgTeamMemberCount -TeamId <String>
Parameters:
Retrieve the member count of a specific team by providing its TeamId.
$teamId = "12345678-90ab-cdef-1234-567890abcdef"
$memberCount = Get-MgTeamMemberCount -TeamId $teamId
Write-Host "The team has $memberCount members."
Note: You may run into errors while using Graph PowerShell cmdlets, since some might still be in development stages like Get-MgTeamMemberCount. But you will have alternatives that you can make use of instead. In our case, you can use Get-MgTeamMember to fetch the team count as shown in the image 2.
Error | Cause | Solution |
Resource not found | This error occurs if the specified TeamId is incorrect or if the team doesn’t exist. | Verify that the TeamId is accurate by using Get-MgTeam to confirm the team exists. You can run:
|
Insufficient Privileges to Complete the Operation | This error indicates that the current user lacks the required permissions. | Ensure your account has Team.ReadBasic.All or Group.Read.All permissions. Re-authenticate with elevated permissions if necessary. |
ServiceUnavailable: The service is temporarily unavailable | This typically occurs when there’s an issue with the Microsoft Graph API service. | Wait a few minutes and try again. If the error persists, check the Microsoft 365 Service Health portal for any ongoing issues. |
The Get-MgTeamMemberCount cmdlet offers a simple and efficient way to track the number of members in a Microsoft Team, which is crucial for maintaining a well-organized Teams environment. With applications in reporting, governance, and real-time monitoring, this cmdlet is indispensable for organizations looking to optimize their use of Microsoft Teams. By combining this cmdlet with other filters or bulk operations, administrators can quickly scale and enhance their management practices for all team sizes.
© m365corner.com. All Rights Reserved. Design by HTML Codex