1 min read

Managing Microsoft Teams with PowerShell

Microsoft Teams management via PowerShell allows for bulk operations, automation of team creation, and configuration of settings not always available in the UI.

Parent Topic: PowerShell Comprehensive Guide Related: Managing Microsoft 365 Groups with PowerShell

Prerequisites

Install the Microsoft Teams module:

Install-Module -Name MicrosoftTeams

Connect to your tenant:

Connect-MicrosoftTeams

Team Management

Create a New Team

New-Team -DisplayName "Finance Dept" -Description "Team for Finance Department" -Visibility Private

Get Teams

# Get all teams the current user belongs to
Get-Team

# Get a specific team by display name (requires filtering)
Get-Team | Where-Object {$_.DisplayName -eq "Finance Dept"}

Archive a Team

$groupId = (Get-Team | Where-Object {$_.DisplayName -eq "Finance Dept"}).GroupId
Set-TeamArchivedState -GroupId $groupId -Archived $true

Channel Management

Create a Standard Channel

New-TeamChannel -GroupId $groupId -DisplayName "Budgeting"

Create a Private Channel

New-TeamChannel -GroupId $groupId -DisplayName "Payroll" -MembershipType Private

Member Management

Add a Member

Add-TeamUser -GroupId $groupId -User "jdoe@yourdomain.com"

Add an Owner

Add-TeamUser -GroupId $groupId -User "admin@yourdomain.com" -Role Owner

Remove a Member

Remove-TeamUser -GroupId $groupId -User "jdoe@yourdomain.com"

Return to PowerShell Comprehensive Guide