New-MgChatMember syntax

Rising Flight 5,256 Reputation points
2025-08-10T18:24:48.1033333+00:00

Hi All,

I want to add a user to a group chat in Teams. I’m using the below syntax but I’m getting the following error:

owner : The term 'owner' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I have tried the following, but no luck:

"roles" = @(owner)

"roles" = @(member)

"roles" = @(guest)

"roles" =@()

Here’s my current script:3f7a29d4-5bc8-4e91-b2c4-d6e3a47b19f2 is my tenant id in script

s1

# Teams chat thread ID
$chatId = "19:48273918273645192837465718273645@thread.v2"
 
# User's UPN (email address)
$userUpn = "******@mydomain.com"   

# Get Object ID for the user
$user = Get-MgUser -UserId $userUpn
 
# Build the request body(in the forum user is coming as  *** so i have used usr)
$body = @{
  "******@odata.type"     = "#microsoft.graph.aadUserConversationMember"
  "******@odata.bind" = "https://graph.microsoft.com/v1.0/users/3f7a29d4-5bc8-4e91-b2c4-d6e3a47b19f2"
  "roles"           = @("owner")   # Must be quoted as strings
}
 
# Add the user to the chat
New-MgChatMember -ChatId $chatId -BodyParameter $body

Microsoft Teams | Microsoft Teams for business | Chats | Group chats
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Hendrix-C 1,205 Reputation points Microsoft External Staff Moderator
    2025-08-10T20:17:55.7733333+00:00

    Hello @Rising Flight,

    Thank you for reaching out to Microsoft Q&A Community.

    You should remove the quotes around the roles key. The right syntax should be roles = @("owner"), not "roles" = @("owner"). You can find more details in New-MgChatMember

    Hope this information is helpful. Please feel free to reach out again if you need any help.

    Looking forward to your response.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 

    0 comments No comments

  2. Hendrix-C 1,205 Reputation points Microsoft External Staff Moderator
    2025-08-12T21:29:18.1066667+00:00

    Good day @Rising Flight,

    Hope things are running smoothly on your end.

    Following up on the support thread we've been working on. Did you have time checking the previous response? If you are still facing the same issue or need assistance with anything else, kindly respond to this email, and I will be happy to help.

    We want to make sure everything is working as expected and that your experience remains uninterrupted.

    Thank you for your patience and understanding throughout the troubleshooting process. 

    I look forward to hearing from you soon.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. Hendrix-C 1,205 Reputation points Microsoft External Staff Moderator
    2025-08-13T21:07:12.3933333+00:00

    Hi @Rising Flight,

    I hope you are having a great day.

    I'm reaching out again to follow up on your issue and check if everything has been resolved. My goal is to ensure your experience remains smooth and hassle-free. If you're still encountering any problems or have run into new challenges, please let me know which steps you're currently stuck on and happy to provide further help whenever you need it. 

    If you have any further questions, feel free to tag me in your reply so I can assist you directly.

    Looking forward to your update.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.