Skip to content

Instantly share code, notes, and snippets.

@dsolodow
Created September 27, 2022 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsolodow/f5c47bf550aaa836fcc61c5c575496af to your computer and use it in GitHub Desktop.
Save dsolodow/f5c47bf550aaa836fcc61c5c575496af to your computer and use it in GitHub Desktop.
Send Teams chat via Graph PS
Import-Module Microsoft.Graph.Teams
$params = @{
ChatType = 'oneOnOne'
Members = @(
@{
'@odata.type' = '#microsoft.graph.aadUserConversationMember'
Roles = @('owner')
'User@odata.bind' = "https://graph.microsoft.com/v1.0/users('UPN')"
}
@{
'@odata.type' = '#microsoft.graph.aadUserConversationMember'
Roles = @('owner')
'User@odata.bind' = "https://graph.microsoft.com/v1.0/users('UPN')"
}
)
}
$chat = New-MgChat -BodyParameter $params
$body = @{
ContentType = 'html'
Content = "Trying something new <at id='0'>Zach</at>"
}
$mentions = @(
@{id = 0
MentionText = 'Zach'
mentioned = @{
User = @{
id = $z.Id
}
}
}
)
New-MgChatMessage -ChatId $chat.Id -Body $body -Mentions $mentions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment