member
1 TopicAdd 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 commands, but non of them I get to work: New-MgUserChatMember --> Throws error when using Add-MgUserChatMember --> Throws error when using Add-MgChatMember --> I don't know how to build BODYPARAMETERS To my script: first I installed all modules of Microsoft-Graph: Install-Module Microsoft.Graph Find-Module Microsoft.Graph.* | Install-Module Then I connected to MS-Graph: Connect-MgGraph Here I get the user which should be added to the chat(s): $user = Get-MgUser -Filter "UserPrincipalName eq 'email address removed for privacy reasons'" Now get the chat groups where to add the user, and add it with the commands above $groups = Get-MgChat -Filter "ChatType eq 'group'" | Where-Object Topic -in $chatgroups foreach ($group in $groups) { New-MgUserChatMember -UserId $user.Id -ChatId $group.Id Add-MgUserChatMember -UserId $user.Id -ChatId $group.Id } But when I run this I get following error messages: New-MgUserChatMember : Requested API is not supported. Please check the path. At N:\Administration\IT\60 Tools\PowerShell\MS-Teams\SyncMSTeamsChatGroupMembers.ps1:93 char:25 + ... New-MgUserChatMember -UserId $user.Id -ChatId $group.Id + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: ({ UserId = 1fe3...rsationMember }:<>f__AnonymousType197`3) [New-MgUserChatMember_CreateExpanded], RestException` 1 + FullyQualifiedErrorId : NotFound,Microsoft.Graph.PowerShell.Cmdlets.NewMgUserChatMember_CreateExpanded Add-MgUserChatMember : 404 page not found At N:\Administration\IT\60 Tools\PowerShell\MS-Teams\SyncMSTeamsChatGroupMembers.ps1:94 char:25 + ... Add-MgUserChatMember -UserId $user.Id -ChatId $group.Id + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: ({ UserId = 1fe3...ionJsonSchema }:<>f__AnonymousType0`3) [Add-MgUserChatMember_AddExpanded1], RestException`1 + FullyQualifiedErrorId : UnknownError,Microsoft.Graph.PowerShell.Cmdlets.AddMgUserChatMember_AddExpanded1 I also tried to get the command Add-MgChatMember to work, but I don't know how to prepare the BODYPARAMS-Attribute, I tried different settings, but always got: AclCheckFailed-Error, seams missing permissions, but I can access the chat and the user info, but can't update it? Is there a special authentication needed. How to implement this? I would appreciate any help, thanks in advance. Rainer3.4KViews0likes1Comment