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