Microsoft Teams PowerShell

Poweshell is simply amazing , it saved more than 3000 hours in my life. It made the impossible possible to work with Microsoft Products seamlessly. when it comes to managing large data sets or user base. It makes life simply easy. Microsoft Teams dynamic membership can happen only on the team level with Azure P1 license . But if you wish to have channels with large user base. PowerShell is your savior.  Otherwise your fingers are going to pain clicking it.  i have made as simple as possible using the existing cmdlets . if you wish to add any additional cmdlets please feel free to leave on comments.

Installing Teams Module

Find-Module MicrosoftTeams
Find-Module MicrosoftTeams | Install-Module


Using pre-Release Modules _ For Example Some Commands Available are only at pre-release

Before using pre-release modules make sure PowerShellGet Runs the latest version

Install-Module PowerShellGet -RequiredVersion

To use pre-release version – (Get-TeamChannelUser is available only on pre release version for now)

Install-Module -Name MicrosoftTeams -RequiredVersion 1.1.3-preview -AllowPrerelease

To use Production version –
Install-Module MicrosoftTeams –RequiredVersion 1.1.4

Production Versions –



To List all Teams



To Get Channels within Team

Get-Team -DisplayName "Information Technology" | Get-TeamChannel


1. Copy Channel Members to another Channel

You can collect the GroupID of the team from the previous command

Get-TeamChannelUser -GroupId "50e33be9-GROUPIDOFTHETEAM4706544ab1a4" -DisplayName "ChannelName"

Now Save it to a Variable from Channel1

$SaveAllMembers = Get-TeamChannelUser -GroupId "50e33be9-GROUPIDOFTHETEAM4706544ab1a4" -DisplayName "ChannelName"


Now Add Same Set of Members to Channel2

$saveallmembers | ForEach-Object{Add-TeamChannelUser -GroupId "50e33be9GROUPIDOFTHETEAM706544ab1a4" -DisplayName "CHANNEL NAME" -User $_.user}


Removing Specific Channel user

Remove-TeamChannelUser -GroupId "50e33be9GROUPIDOFTHETEAM-4706544ab1a4" -DisplayName "Channel name" –User ""


Export Channel Members to CSV –

Get-TeamChannelUser -GroupId "50e33be9GROUPIDOFTHETEAM-4706544ab1a4" -DisplayName "Channel Name" | Select-Object User | Export-Csv TeamsChannelMembers.csv


Removing Members from Channels using CSV

Import-Csv .\TeamsChannelMembers.csv
Import-Csv .\TeamsChannelMembers.csv | ForEach-Object{Remove-TeamChannelUser -GroupId "50e33be9-GROUPIDOFTHETEAM-4706544ab1a4" -DisplayName "SD - NET" -User $_.User}


Adding Channel Members using CSV

Import-Csv .\TeamsChannelMembers.csv | ForEach-Object{Add-TeamChannelUser -GroupId "50e33be9GROUPIDOFTHETEAM-4706544ab1a4" -DisplayName "Channel Name" -User $_.User}

Adding Team Members using CSV

Import-Csv .\TeamsMembers.csv | ForEach-Object{Add-TeamUser -GroupId "000faf41-7fa8-0000-ac2d-2c180000af77" -User $_.User}}

To Display All Teams and Channels

Get-Team | ForEach-Object{Get-TeamChannel -GroupID $_.GroupID | FT DisplayName,Description,MembershipType}


Good to have – To Use Different Repositories –

Register-PSRepository –Name '_TempTestRepo' –SourceLocation ''

To List Registered Repositories –

Get-PSRepository | Fl 
Microsoft Remove - Pre-Release Versions from below Location -

If you hit below error - Update PowershellGet and Restart Powershell
PS C:\Scripts> Install-Module -Name MicrosoftTeams -RequiredVersion 1.1.3-preview -AllowPrerelease
Install-Module : Cannot process argument transformation on parameter 'RequiredVersion'. Cannot convert value
"1.1.3-preview" to type "System.Version". Error: "Input string was not in a correct format."
At line:1 char:54
+ ... ll-Module -Name MicrosoftTeams -RequiredVersion 1.1.3-preview -AllowP ...
+ CategoryInfo          : InvalidData: (:) [Install-Module], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Install-Module

About Satheshwaran Manoharan

Satheshwaran Manoharan is an Microsoft Office Server and Services MVP , Publisher of Specialized in Office365 / Microsoft Exchange / Virtualization , Sathesh is an Messaging Expert supporting/Designing/Deploying many medium size businesses to large enterprises when it comes to Corporate messaging and Virtualization Infrastructure

Check Also

Azure B2C White label URLs with Azure Front Door

Azure B2C is allowing white label URLs through Azure Front Door now. it was a …


  1. hey im curious if its possible to use this module to directly manipulate chat conversations or if such a module exists. Specifically Im hoping to clear out conversations older than a specific age.

  2. Hi, I followed the instructions step by step, but I have this error message:
    Get-TeamChannelUser : The term ‘Get-TeamChannelUser’ is not recognized as a cmdlet name, function, executable program or script file. Check the spelling of the name or verify that the path is included and correct, then try again.
    In riga:1 car:1
    + Get-TeamChannelUser
    + ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Get-TeamChannelUser:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Can you help me ?
    thankyou !

  3. This was very helpful. I am receiving an error “BadGateway” when I attempt to modify your script to include “Role”. Am I doing something wrong?

    Import-Csv .\addChannelUsers.csv | ForEach-Object{Add-TeamChannelUser -GroupId $GroupId -DisplayName $_.cdisplayname -User $_.cuser -Role $_.crole}

  4. Display All Teams and Channels – Get-Team | ForEach-Object{Get-TeamChannel -GroupID $_.GroupID | FT DisplayName,Description,MembershipType}

    How do I export to CSV? I added Export-CSV but it doesn’t show all the info as it does when listing on PS. I’d like to export all Teams channels/groups their owners and members for each channel.
    Pls help! Thx!

Leave a Reply

Your email address will not be published.