Dec 01 2021 02:14 PM
Hi
Do you know of a way I can add few people to multiple private channels at the same time within a team?
Dec 01 2021 02:28 PM
Dec 02 2021 11:19 AM
Dec 04 2021 02:29 AM
@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"