Bulk create private Teams & channels with Owners & users

Prateek Singhal 1 Reputation point
2022-10-17T11:12:59.9+00:00

Hey there fellas,

I'm setting up Teams for my organization.

One team layout requires around 15 private channels (representing different cities/countries) and by default, there's a small group of users (core team) that need to be in ALL of the private Teams & channels with the Owner's permission and others as members.

Example:

Team name: FINANCE

A fixed set of users that need to be in all private channels: Brent, Chaz, Isabelle, Jose, etc.

Private channels:

Berlin

London

Madrid

Milan

Paris

...

15th city/country

And the same layout will need to be applied for the other 10 teams (LOGISTICS, SALES, etc), only the set of additional users is different.

Creating all of this manually is of course possible, but it's very tedious. I started reading and found a couple of articles explaining how to do it in bulk, using Powershell, which is something that I have limited experience with. But I can manage, as long as the instructions are easy to follow.

Please help. Thank you!

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,456 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,399 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kael Yao-MSFT 37,661 Reputation points Microsoft Vendor
    2022-10-18T09:33:11.33+00:00

    Hi @Prateek Singhal

    Kindly note that Teams forum mainly supports Teams general questions.
    Since this question is related to scripting, I would suggest posting in scripting forums for better support.
    Thanks for your understanding.

    If I understand your requirement correctly, you need to add these specific users (as owner and member) to all the private channels.

    If I misunderstood it, please feel free to correct me.


    Are the users (core team) added to the FINANCE Team already?
    If yes, please prepare three csv files for channels, members and owners.
    The format would be like:
    251517-04.png

    251518-05.png

    251572-06.png

    Then use the following script to see if it can work for you:

    $team = Get-Team -DisplayName "Finance3"  
    $channels = import-csv "C:\temp\channel.csv"  
    Foreach($channel in $channels)  
    {  
    	New-TeamChannel -GroupId $team.groupid -DisplayName $channel.Name -MembershipType Private  
    }  
      
    $members = import-csv "C:\temp\member.csv"  
    Foreach($member in $members)  
    {  
    	Foreach($channel in $channels)  
    	{  
    		Add-TeamChannelUser -GroupID $team.groupid -DisplayName $channel.Name -User $member.Email		  
    	}  
    }  
      
    $owners = import-csv "C:\temp\owner.csv"  
    Foreach($owner in $owners)  
    {  
    	Foreach($channel in $channels)  
    	{  
    		Add-TeamChannelUser -GroupID $team.groupid -DisplayName $channel.Name -User $owner.Email  
    		Add-TeamChannelUser -GroupID $team.groupid -DisplayName $channel.Name -User $owner.Email -Role Owner		  
    	}  
    }  
    

    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.

    1 person found this answer helpful.

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.