Microsoft Teams and Skype for Business thoughts and news

Tom Arbuthnot MVP
Tom Arbuthnot MCSM Communications

This site uses cookies

Find this blog useful? Please take a second to share, thanks!

Microsoft Teams PowerShell: Getting All Teams, Changing Team Settings and Adding and Removing Users from Teams

Published 25/10/2018 - 0 Comments

As of Microsoft Teams PowerShell 0.95, you can now get and administer all Microsoft Teams as an Office 365 administrator. Previous to 0.95 release, it only worked for teams the current user running the PowerShell was a member of, which made it too limited for any real administration.

First, run PowerShell as a local administrator and install the Module

Install-Module -Name MicrosoftTeams -Repository PSGallery

image

If you get a warning about an old version, you can first uninstall the old version with Uninstall-Module MicrosoftTeams

image

Then connect, you will get prompted for credentials

Connect-MicrosoftTeams

image

Cmdlets available:

image

Get-Team now gets all Teams in your org, not just the ones you are a member of:

image

Get Team Members and Owners (note it uses GroupId not DisplayName:

image

Add a Member to a Team. Can be either a Public or Private Team

image

image

Remove Member from a Team

image

Remove-TeamUser doesn’t seem to put a message into the general channel

image

But the member is removed:

image

There are no confirmation of successful actions, but you will get errors if references or syntax are wrong:

image

Simple script to add a user to all Teams (we use this for reporting)

# Install the Microsoft Teams PowerShell Module from PSGallery
# Default install Path C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams
Install-Module -Name MicrosoftTeams -Repository PSGallery

# Connect to Microsoft Teams
Connect-MicrosoftTeams

# Script to Get all Teams and Add an account as a memeber

$UserToAdd = “[email protected]

$AllTeams = Get-Team

Foreach ($Team in $AllTeams)
{
Write-Host “Adding to $($Team.DisplayName)”
Add-TeamUser -GroupId $Team.GroupID -User $UserToAdd -Role Member
#Sleep Pause so as not to hit the API to hard
Start-Sleep -Seconds 2
}

You can also create new teams and channels, and get and change settings for Teams:

image

image

image

image

image

Reference

Module: https://www.powershellgallery.com/packages/MicrosoftTeams/0.9.5

Teams Help: https://docs.microsoft.com/en-us/powershell/module/teams/?view=teams-ps

Tom Arbuthnot

Tom Arbuthnot

Principal Solutions Architect at Modality Systems
Tom Arbuthnot is Principal Solutions Architect at Unified Communications specialist Modality Systems. He is a Microsoft Certified Master and MVP, blogger, has a regular podcast with UCToday at tomtalks.show and is a regular speaker at events including Microsoft TechEd and Ignite. He co-runs The Microsoft UC User Group London.

No comments yet

Leave a Reply:


close

Weekly Email Update 
of all the key 
Microsoft Teams and Skype for Business News
every Tuesday

No Spam ever, I promise - Tom