Forum Discussion
PS-Rainer
Sep 16, 2022Copper Contributor
Add user to teams chat
Hi, I want to add an exising user to a team chat with PowerShell, but I can't find a working solution in the documentation or on google, hopefulle someone can help here: I found following comman...
raindropsdev
Sep 28, 2022Iron Contributor
When taking a look directly at the API call used it appears that the command is New-MgChatMember:
https://learn.microsoft.com/en-us/graph/api/chat-post-members?view=graph-rest-1.0&tabs=powershell
Import-Module Microsoft.Graph.Teams
$params = @{
"@odata.type" = "#microsoft.graph.aadUserConversationMember"
"email address removed for privacy reasons" = "https://graph.microsoft.com/v1.0/users/8b081ef6-4792-4def-b2c9-c363a1bf41d5"
VisibleHistoryStartDateTime = [System.DateTime]::Parse("2019-04-18T23:51:43.255Z")
Roles = @(
"owner"
)
}
New-MgChatMember -ChatId $chatId -BodyParameter $params
Uh, it appears that techcommunity breaks stuff with the email protection, I recommend you look at the code directly in Microsoft Docs