Get-MgmtGraphUserMessageContent
MgmtGraph: Retrieves user message content
#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Mail
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true, Position = 0)]
[string]$Identity,
[Parameter(Mandatory = $true)]
[string]$MessageId,
[Parameter(Mandatory = $true)]
[string]$Path
)
Process {
try {
$params = @{
'UserId' = $Identity
'MessageId' = $MessageId
'OutFile' = $Path
'ErrorAction' = 'Stop'
}
Get-MgUserMessageContent @params
$result = [PSCustomObject]@{
UserId = $Identity
MessageId = $MessageId
SavedPath = $Path
Action = "MessageContentExported"
Status = "Success"
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
}
Write-Output $result
}
catch {
throw
}
}Specifies the UserPrincipalName or ID of the user.
Specifies the ID of the message to retrieve.
Specifies the file path where the message content will be saved.