Thursday , May 14 2020

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

image

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

Register-PSRepository –Name '_TempTestRepo' –SourceLocation 'https://www.poshtestgallery.com'
Get-PSRepository | Fl
Install-Module MicrosoftTeams –RequiredVersion 1.0.20

clip_image001

Production Versions – https://www.powershellgallery.com/packages/MicrosoftTeams

Pre-Release Versions – https://www.poshtestgallery.com/packages/MicrosoftTeams

Connect-MicrosoftTeams

image

To List all Teams

Get-Team

image

To Get Channels within Team

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

image

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"

image

Now Add Same Set of Members to Channel2

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

image

Removing Specific Channel user

Remove-TeamChannelUser -GroupId "50e33be9GROUPIDOFTHETEAM-4706544ab1a4" -DisplayName "Channel name" –User "zulqar@azure365pro.com"

image

Export Channel Members to CSV –

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

image

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}

image

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}

About Satheshwaran Manoharan

Satheshwaran Manoharan is an Microsoft Office Server and Services MVP , Publisher of Azure365pro.com. 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

Leaving the Organization as guest in Teams

Leaving the Organization in teams is certainly important . So that you can come out …

2 comments

  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.

Leave a Reply

Your email address will not be published.