Adding an existing Microsoft 365 group to MS Team as a member.

H Mohamed 1 Reputation point

Hi all,

I am looking for some assistance regarding PowerShell script.

I have managed to create Teams “Class-Test-2021” however; I would now like to add an existing Microsoft 365 group “Test-01” to the team as a member. How can I do this using PowerShell?

Thank you in advance

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
8,657 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
827 questions
Microsoft 365 Publishing
Microsoft 365 Publishing
Microsoft 365: Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line. Publishing: The process of preparing, producing, and releasing content for distribution or sale.
587 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
18,626 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Manu Philip 16,901 Reputation points MVP

    Open PowerShell as administrator and follow the steps

    Type Install-Module MicrosoftTeams (if you don't have the cmdlets installed)

    Type Connect-MicrosoftTeams and log in

    Type Get-UnifiedGroup -Identity <Group> | fl ExternalDirectoryObjectId

    Type New-Team -Group <ExternalDirectoryObjectId of Group>

    0 comments No comments

  2. Vasil Michev 90,881 Reputation points MVP

    You cannot nest Groups/Teams, that's not supported. In fact, when you try to do it via the UI, the current membership of the group will be expanded and added to the Team, this is what Microsoft supports.
    Afaik Microsoft is working on support for this scenario, so check the Roadmap.

    0 comments No comments

  3. Sharon Zhao-MSFT 25,126 Reputation points Microsoft Vendor

    @H Mohamed ,

    I tried lots of research but find no direct command to realize this. So, it needs some more scripts to accomplish it. As script is not in our service scope, I will just provide a simple train of thought. Thanks for your understanding.

    Firstly, you could get the members’ email address of “Test-01” group by Get-UnifiedGroupLinks command:

    Get-UnifiedGroupLinks -Identity <Test-01 GroupId> -LinkType Members  

    Then, use Add-TeamUser command to add all the members to “Class-Test-2021” group. Here we need a loop statement, such as Foreach:

    Add-TeamUser GroupId <Class-Test-2021 group Id> -User <member’s email address>  

    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

  4. H Mohamed 1 Reputation point

    Dear ManuPhilip/Michev/SharonZhao,

    Thank you kindly for your prompt response and to your suggestions to my question. I will continue with the search and came back when I have something to share.

    Many thanks