Skip to content

Get-MgmtGraphGroupConversationThread

MgmtGraph: Retrieves group conversation threads

#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Groups

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true, Position = 0)]
    [string]$GroupId,

    [Parameter(Mandatory = $true, Position = 1)]
    [string]$ConversationId
)

Process {
    try {
        $params = @{
            'GroupId'        = $GroupId
            'ConversationId' = $ConversationId
            'All'            = $true
            'ErrorAction'    = 'Stop'
        }

        $threads = Get-MgGroupConversationThread @params
        
        $results = foreach ($t in $threads) {
            [PSCustomObject]@{
                GroupId               = $GroupId
                ConversationId        = $ConversationId
                ThreadId              = $t.Id
                Topic                 = $t.Topic
                Preview               = $t.Preview
                LastDeliveredDateTime = $t.LastDeliveredDateTime
                HasAttachments        = $t.HasAttachments
                IsLocked              = $t.IsLocked
                UniqueSenders         = ($t.UniqueSenders -join "; ")
                Timestamp             = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
            }
        }

        Write-Output $results
    }
    catch {
        throw
    }
}

The unique identifier of the Microsoft Graph group.

The unique identifier of the target conversation.

An interactive directory of PowerShell scripts.