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
If you get a warning about an old version, you can first uninstall the old version with Uninstall-Module MicrosoftTeams
Then connect, you will get prompted for credentials
Connect-MicrosoftTeams
Cmdlets available:
Get-Team now gets all Teams in your org, not just the ones you are a member of:
Get Team Members and Owners (note it uses GroupId not DisplayName:
Add a Member to a Team. Can be either a Public or Private Team
Remove Member from a Team
Remove-TeamUser doesn’t seem to put a message into the general channel
But the member is removed:
There are no confirmation of successful actions, but you will get errors if references or syntax are wrong:
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 = “TWA.Reporting@domain.com”
$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:
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