Skip to content

Get-MgmtGraphGroupThreadPost

MgmtGraph: Retrieves posts inside a conversation thread

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

    [Parameter(Mandatory = $true, Position = 2)]
    [string]$ConversationThreadId,

    [ValidateSet('ReceivedDateTime', 'Id', 'CreatedDateTime', 'HasAttachments', 'Attachments', 'LastModifiedDateTime', 'MultiValueExtendedProperties', 'Extensions', 'ChangeKey', 'Categories')]
    [string[]]$Properties = @('Id', 'CreatedDateTime', 'ReceivedDateTime', 'LastModifiedDateTime', 'HasAttachments')
)

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

        Write-Output $results
    }
    catch {
        throw
    }
}

The unique identifier of the Microsoft Graph group.

The unique identifier of the conversation.

The unique identifier of the conversation thread.

Optional. List of properties to select. Default includes Id, CreatedDateTime, ReceivedDateTime, LastModifiedDateTime, HasAttachments.

An interactive directory of PowerShell scripts.