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

H Mohamed 1 Reputation point
2021-11-24T15:53:11.137+00:00

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.
9,161 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
883 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.
598 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,684 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Manu Philip 16,991 Reputation points MVP
    2021-11-24T15:58:08.073+00:00

    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 96,161 Reputation points MVP
    2021-11-24T16:05:20.233+00:00

    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,056 Reputation points Microsoft Vendor
    2021-11-25T02:56:02.11+00:00

    @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
    2021-11-26T11:06:06.87+00:00

    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
    Hamza