Adding member to multiple private channels

%3CLINGO-SUB%20id%3D%22lingo-sub-3024963%22%20slang%3D%22en-US%22%3EAdding%20member%20to%20multiple%20private%20channels%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3024963%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3EDo%20you%20know%20of%20a%20way%20I%20can%20add%20few%20people%20to%20multiple%20private%20channels%20at%20the%20same%20time%20within%20a%20team%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3024963%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EHow-to%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3025021%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20member%20to%20multiple%20private%20channels%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3025021%22%20slang%3D%22en-US%22%3EHi!%3CBR%20%2F%3EThe%20only%20way%20is%20programmatically%2C%20not%20from%20UI.%3CBR%20%2F%3E%3CBR%20%2F%3EAdam%3C%2FLINGO-BODY%3E
Occasional Visitor

Hi

Do you know of a way I can add few people to multiple private channels at the same time within a team?

4 Replies
Hi!
The only way is programmatically, not from UI.

Adam
Programmatically = PowerShell too ;)
Yup, correct!

@MadhuMalie You can use the below script to do it. This script adds list of users from csv and it to all the private channels to the team, customize it as per your requirement.

 

# Add a memeber to multiple private channel in single team
# First install the modules...
# Install-Module MicrosoftTeams
 function Add-MemberPrivatechannel
 {
    param (
    $TeamName,$ImportPath
    )
    process
    {
            # Connect to the Teams module
            Connect-MicrosoftTeams
            
            $GroupId = (Get-Team -DisplayName "$TeamName").GroupId
            #Get private channel
            $allprivatechannel= Get-TeamChannel -GroupId $GroupId -MembershipType Private
            #Add the username in the csv file
            $AllUsers= Import-Csv -Path $ImportPath 
            #Add a Member to privatechanel
            foreach($privatechannel in $allprivatechannel)
            {
                foreach($Users in $AllUsers){   
                $privatechannelname=$privatechannel.DisplayName
                Add-TeamChannelUser -GroupId $GroupId -DisplayName "$privatechannelname" -User $Users.UserPrincipalName
                }
            }
    }
}
Add-MemberPrivatechannel -TeamName "Design" -ImportPath "C:\Userfile\Userlist.csv"