Skip to content

Get-MgmtGraphGroupThread

MgmtGraph: Retrieves conversation threads inside a group conversation

#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,

    [ValidateSet('Preview', 'Id', 'LastDeliveredDateTime', 'IsLocked', 'HasAttachments', 'UniqueSenders', 'Topic', 'Posts', 'CcRecipients', 'ToRecipients')]
    [string[]]$Properties = @('Preview', 'Topic', 'Id', 'LastDeliveredDateTime', 'HasAttachments', 'IsLocked')
)

Process {
    try {
        $threads = Get-MgGroupThread -GroupId $GroupId -ConversationId $ConversationId -All -ErrorAction Stop
        
        $results = foreach ($t in $threads) {
            $obj = [PSCustomObject]@{
                GroupId        = $GroupId
                ConversationId = $ConversationId
                Timestamp      = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
            }
            foreach ($p in $Properties) {
                $obj | Add-Member -MemberType NoteProperty -Name $p -Value $t.$p -Force
            }
            $obj
        }

        Write-Output $results
    }
    catch {
        throw
    }
}

The unique identifier of the Microsoft Graph group.

The unique identifier of the conversation.

Optional. List of properties to select. Default includes Preview, Topic, Id, LastDeliveredDateTime, HasAttachments, IsLocked.

An interactive directory of PowerShell scripts.