Microsoft Teams
List messages in a Microsoft Teams channel
Use Microsoft Graph or its PowerShell cmdlet to retrieve top-level channel messages. Thread replies require a separate request or an explicit expansion.
Documentation reviewed · 2 methods with sources
Ways to do it
API
GET /teams/{team-id}/channels/{channel-id}/messages
List messages for a channel. Use the response’s next link to continue paging.
Read source: Microsoft Graph channel messages- Requirements
- The team and channel IDs and an authorized Microsoft Graph token. The least-privileged scope is ChannelMessage.Read.All for delegated work accounts or ChannelMessage.Read.Group for applications using resource-specific consent.
- Limitations
- The endpoint returns 50 messages per page at most. Replies are omitted by default.
CLI
Get-MgTeamChannelMessage
Use Microsoft Graph PowerShell and pass -All to page through the available results.
Read source: Microsoft Graph PowerShell command reference- Requirements
- The Microsoft.Graph.Teams PowerShell module, an authenticated Graph session with message-read access, and team and channel IDs.
- Limitations
- Paging collects top-level messages. Without -ExpandProperty replies or a separate replies call, it leaves out thread replies.
Example text
Get-MgTeamChannelMessage -TeamId $teamId -ChannelId $channelId -All