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

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
446 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.
491 questions
Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
12,640 questions
Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
5,316 questions
No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Manu Philip 14,036 Reputation points Microsoft 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>

    No comments

  2. Vasil Michev 61,906 Reputation points Microsoft 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.

    No comments

  3. Sharon Zhao-MSFT 24,656 Reputation points Microsoft Employee

    @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.

    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