Skip to content

Get-MgmtGraphGroupConversation

MgmtGraph: Retrieves group conversations

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

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

    [string]$ConversationId
)

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

        if ($ConversationId) {
            $params.Add('ConversationId', $ConversationId)
        }
        else {
            $params.Add('All', $true)
        }

        $conversations = Get-MgGroupConversation @params
        
        $results = foreach ($c in $conversations) {
            [PSCustomObject]@{
                GroupId               = $GroupId
                ConversationId        = $c.Id
                Topic                 = $c.Topic
                Preview               = $c.Preview
                LastDeliveredDateTime = $c.LastDeliveredDateTime
                HasAttachments        = $c.HasAttachments
                UniqueSenders         = ($c.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.

Optional. The unique identifier of a specific conversation to retrieve.

An interactive directory of PowerShell scripts.