Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,891 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi All
I want to add users to a Teams channel. Could someone please validate the syntax and let me know if it is correct? i have not tested it.
$teamGroupId = "Microsoft 365 Group ID"
$channelDisplayName = "your_private_channel_name"
# Path to the CSV file (ensure it has a column named 'UserEmail')
$csvPath = "C:\temp\list.csv"
$users = Import-Csv -Path $csvPath
Connect-MicrosoftTeams
foreach ($user in $users) {
$email = $user.UserEmail
if ($email) {
try {
Add-TeamChannelUser -GroupId $teamGroupId -DisplayName $channelDisplayName -User $email -ErrorAction Stop
Write-Host "Successfully added $email to channel $channelDisplayName"
} catch {
Write-Warning "Failed to add $email: $_"
}
} else {
Write-Warning "Missing UserEmail in CSV row: $($user | Out-String)"
}
}