Created
September 27, 2022 17:11
-
-
Save dsolodow/f5c47bf550aaa836fcc61c5c575496af to your computer and use it in GitHub Desktop.
Send Teams chat via Graph PS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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