Showing posts with label channel. Show all posts
Showing posts with label channel. Show all posts

Monday, 9 August 2021

Microsoft Teams - Add Members to Private Channel using Powershell

If you have a large number of members you need to add to a private channel in teams, you may wish to use powershell to do so as it can be much faster than manually adding users via the Teams app, or web management interface.

Note that you will need to install the preview/prerelease version of the Microsoft Teams powershell module to get access to the cmdlet that we're using here (refer to my separate blog post on how to do this)

Add-TeamChannelUser -GroupID "abc123456789" -Displayname "privatechannelname" -user "user@domain.com"

Be sure to update the Group ID with the unique Group ID of your target team - and the displayname should match the displayname of the private channel you wish to add the user to.

Note that adding users via this cmdlet can cause them to not show in the actual team for some time (in my experience 15-30 mins) so you may need to allow some time before checking/confirming they appear in the channel user list

Friday, 6 August 2021

Microsoft Teams - teamchanneluser cmdlet is not recognized

Microsoft Teams features some commands (cmdlets) that are not readily available in the public/general release version of the Microsoft Teams powershell module. Some of these commands are;

get-teamchanneluser

add-teamchanneluser

If you attempt to run these commands, you'll get an error message like the one below;

get-teamchanneluser : The term 'get-teamchanneluser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At line:1 char:1

To fix the problem you will need to install the preview release of the Microsoft Teams powershell module. You can check the release version numbers from the website below

https://www.powershellgallery.com/packages/MicrosoftTeams/2.0.0

To install the preview release version, make note of the version number then run the command below

Install-Module -Name MicrosoftTeams -AllowPrerelease

To fix the problem you need to force an update of a couple of Powershell modules - namely PowershellGet and PackageManagement. 

Install-Module : A parameter cannot be found that matches parameter name 'AllowPrerelease'.

At line:1 char:37

Run the commands below from an elevanted powershell command prompt;

Install-Module -Name PowerShellGet -Repository PSGallery -Force
Install-Module -Name PackageManagement -Repository PSGallery -Force

Exit/close your Powershell window/session then re-open and run the install-module command again - it should now complete successfully

You can confirm what version is installed by running the commands

import-module "MicrosoftTeams"

get-module

Look for the version number for the "MicrosoftTeams" module