The Get-MgTeamChannelMember cmdlet is a powerful tool for administrators to retrieve details about the members of a specific Microsoft Teams channel. This cmdlet is essential for managing and auditing channel membership within an organization. In this article, we will explore the syntax, usage examples, tips, common errors with solutions, and use cases to help you get the most out of this cmdlet.
Get-MgTeamChannelMember -TeamId <String> -ChannelId <String>
Get-MgTeamChannelMember -TeamId "d58a6e74-23a5-46db-a13f-b9a5625f9f1a" -ChannelId "19:737f2e5b6c4d4d46905d2f1b4bcf6f34@thread.tacv2"
This example retrieves all members of a specific channel within a team.
Get-MgTeamChannelMember -TeamId "d58a6e74-23a5-46db-a13f-b9a5625f9f1a" -ChannelId "19:737f2e5b6c4d4d46905d2f1b4bcf6f34@thread.tacv2" -Filter "roles/any(r: r eq 'owner')"
In this example, we retrieve all members of a channel who have the role of "owner".
Cause: The specified TeamId or ChannelId does not exist, or the user does not have access.
Solution: Verify that the TeamId and ChannelId are correct and that you have the necessary permissions to access the team and channel.
Cause: The -Filter parameter was used incorrectly or with unsupported query options.
Solution: Review the OData query documentation and ensure that the filter syntax is correct. Common mistakes include incorrect property names or unsupported query operators.
The Get-MgTeamChannelMember cmdlet is an invaluable tool for managing and auditing Microsoft Teams channels. By understanding its syntax, parameters, and common errors, administrators can efficiently retrieve and filter channel member data, ensuring that team communication is secure and well-managed. Whether you are conducting routine audits or automating membership reports, this cmdlet offers the flexibility and power needed to maintain an organized and secure Teams environment.
The /teams/{team-id}/channels/{channel-id}/members endpoint lets you retrieve channel members in a Microsoft Team. You can optionally filter members based on their role (like owner, member, or guest) using client-side filtering in PowerShell.
Example 1: Get All Channel Members
This example retrieves all members of a specific channel.
$teamId = "d58a6e74-23a5-46db-a13f-b9a5625f9f1a"
$channelId = "19:737f2e5b6c4d4d46905d2f1b4bcf6f34@thread.tacv2"
$uri = "https://graph.microsoft.com/v1.0/teams/$teamId/channels/$channelId/members"
$response = Invoke-MgGraphRequest -Method GET -Uri $uri
foreach ($member in $response.value) {
Write-Output "User ID : $($member.userId)"
Write-Output "Roles : $($member.roles -join ', ')"
Write-Output "`n"
}
✅ Equivalent to:
Get-MgTeamChannelMember -TeamId "<team-id>" -ChannelId "<channel-id>"
Example 2: Filter Channel Members by User Role (e.g., Owner)
Since the /members endpoint does not support server-side $filter on roles, we must filter on the client side in PowerShell:
$teamId = "d58a6e74-23a5-46db-a13f-b9a5625f9f1a"
$channelId = "19:737f2e5b6c4d4d46905d2f1b4bcf6f34@thread.tacv2"
$uri = "https://graph.microsoft.com/v1.0/teams/$teamId/channels/$channelId/members"
$response = Invoke-MgGraphRequest -Method GET -Uri $uri
$owners = $response.value | Where-Object { $_.roles -contains "owner" }
foreach ($owner in $owners) {
Write-Output "Owner User ID: $($owner.userId)"
}
⚠️ Note: $filter is not supported for roles in this endpoint, so filtering must be performed after retrieving all data.
Required Permissions
| Context | Permission |
| Delegated | ChannelMember.Read.All |
| Application | ChannelMember.Read.All |
Graph API Documentation
© m365corner.com. All Rights Reserved. Design by HTML Codex