Adding member to multiple private channels

Copper Contributor

Hi

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

5 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"