In Part 1 of our Microsoft Teams PowerShell series, we audited Teams using Get-Team, Get-TeamChannel, and Get-TeamUser. In Part 2, we hardened Team governance policies using Set-Team and Set-TeamChannel.
In Part 3, we complete the lifecycle by covering automated provisioning and decommissioning:
New-Team(Creating a brand-new Team or team-enabling an existing Microsoft 365 Unified Group)New-TeamChannel(ProvisioningStandard,Private, and B2BSharedchannels)Add-TeamUser(Adding Owners, Members, and Guests individually or in bulk via CSV)Remove-TeamChannel,Remove-TeamUser, andRemove-Team(Archiving vs. Soft-Deleting Teams)
Microsoft Teams PowerShell Lifecycle Architecture (New-, Add-, Remove-*)
1. New-Team: Provision a Brand-New Team (or Team-Enable an Existing M365 Group)
In the original 0.9.x preview of the module, New-Team used -Alias and -AccessType. In modern MicrosoftTeams (v6+), those parameters were standardized to -MailNickName and -Visibility (Private or Public), and you can set all governance guardrails directly during creation:
# Connect to Microsoft Teams
Connect-MicrosoftTeams
# 1. Create a new Private Project Team with hardened member/guest settings from Day 1
$NewTeam = New-Team -DisplayName "New Project Team" `
-Description "Cross-functional engineering workspace for Project Alfa" `
-MailNickName "NewPTeam" `
-Visibility "Private" `
-Owner "[email protected]" `
-AllowCreateUpdateChannels $false `
-AllowDeleteChannels $false `
-AllowGuestCreateUpdateChannels $false `
-AllowGuestDeleteChannels $false
Write-Host "[+] Created Team '$($NewTeam.DisplayName)' with GroupId: $($NewTeam.GroupId)" -ForegroundColor Green
# 2. Alternative: Team-Enable an EXISTING Microsoft 365 Unified Group (e.g., 'Compliance Admins')
# New-Team -GroupId "f8092e73-ed1b-4826-92a9-b9c1e408761b"
Tip: Always capture the output ofNew-Teaminto a variable ($NewTeam) so you can immediately pass$NewTeam.GroupIdintoNew-TeamChannelandAdd-TeamUser.
2. New-TeamChannel: Create Standard, Private, and Shared Channels
Using New-TeamChannel, you can provision traditional Standard channels (visible to everyone in the Team), Private channels (restricted to a subset of Team members with an isolated SharePoint site collection), or Shared channels (for B2B Direct Connect collaboration without switching tenants):
$GroupId = $NewTeam.GroupId # Or "255d4a49-5076-42c8-a109-45252a7244a7"
# 1. Create a Standard Channel
New-TeamChannel -GroupId $GroupId `
-DisplayName "Project Alfa" `
-Description "Main engineering sprint discussions and deliverables" `
-MembershipType Standard
# 2. Create a Private Channel (Requires specifying an existing Team Owner via -Owner)
New-TeamChannel -GroupId $GroupId `
-DisplayName "Project Alfa - Budget & Contracts" `
-Description "Confidential vendor contracts and financial tracking" `
-MembershipType Private `
-Owner "[email protected]"
# 3. Create a Shared Channel
New-TeamChannel -GroupId $GroupId `
-DisplayName "Project Alfa - External Partner Sync" `
-MembershipType Shared `
-Owner "[email protected]"
3. Add-TeamUser: Add Owners and Members to a Team (or Private Channel)
With Add-TeamUser, you can add users as a Member (default) or Owner, and even scope membership to a specific Private Channel using -DisplayName:
$GroupId = "255d4a49-5076-42c8-a109-45252a7244a7"
# 1. Add a regular Member to the Team
Add-TeamUser -GroupId $GroupId -User "[email protected]" -Role Member
# 2. Promote or add a secondary Team Owner (Always maintain at least 2 Owners per Team!)
Add-TeamUser -GroupId $GroupId -User "[email protected]" -Role Owner
# 3. Add a Team Member into a specific Private Channel
Add-TeamUser -GroupId $GroupId `
-DisplayName "Project Alfa - Budget & Contracts" `
-User "[email protected]"
# 4. Bulk Onboard Users from a CSV File (Columns: UPN, Role)
Import-Csv "C:\Temp\ProjectAlfaRoster.csv" | ForEach-Object {
Add-TeamUser -GroupId $GroupId -User $_.UPN -Role $_.Role
Write-Host "[+] Added $($_.UPN) as $($_.Role)" -ForegroundColor Cyan
}
4. Remove-TeamChannel: Delete a Channel from a Team
When a workstream concludes, remove the channel using Remove-TeamChannel (note that the default General channel cannot be deleted):
$GroupId = "255d4a49-5076-42c8-a109-45252a7244a7"
Remove-TeamChannel -GroupId $GroupId -DisplayName "Project Alfa"
Deleted channels enter a 30-day soft-delete retention window during which they can be restored in the Teams Admin Center or client UI.
5. Remove-TeamUser: Remove a Member, Guest, or Owner from a Team
To offboard a user or revoke guest access from a specific Team, run Remove-TeamUser:
$GroupId = "255d4a49-5076-42c8-a109-45252a7244a7"
# Remove a user from the entire Team
Remove-TeamUser -GroupId $GroupId -User "[email protected]"
# Or remove a user strictly from a Private Channel while keeping them in the parent Team
Remove-TeamUser -GroupId $GroupId `
-DisplayName "Project Alfa - Budget & Contracts" `
-User "[email protected]"
6. Set-TeamArchivedState vs. Remove-Team: Safely Decommissioning a Team
Before running Remove-Team, decide whether you want to Archive (freeze) the Team or Delete it:
Option A: Archive the Team (Set-TeamArchivedState — Recommended for Completed Projects)
Archiving freezes all channel conversations and optionally makes the backing SharePoint site read-only for members while preserving all compliance data:
Set-TeamArchivedState -GroupId "255d4a49-5076-42c8-a109-45252a7244a7" `
-Archived $true `
-SetSpoSiteReadOnlyForMembers $true
Option B: Delete the Team (Remove-Team)
If the Team was created for testing or is no longer needed, delete it via Remove-Team:
Remove-Team -GroupId "255d4a49-5076-42c8-a109-45252a7244a7"
Accidentally ranRemove-Teamon a production Team? Don't panic!Remove-Teammoves the underlying Microsoft 365 Unified Group into the Entra ID 30-day soft-deleted recycle bin. Follow our emergency recovery runbook—How to Restore Deleted Microsoft 365 Groups and Microsoft Teams via PowerShell—to restore the Team, its channels, and its SharePoint files completely intact.
Complete Microsoft Teams PowerShell Series Index
- Prerequisite: How to Install and Connect to the Microsoft Teams PowerShell Module
- Part 1: Auditing Teams, Channels, and Users (
Get-Team,Get-TeamChannel,Get-TeamUser) - Part 2: Modifying Team Settings & Governance (
Set-Team,Set-TeamChannel,Set-TeamPicture) - Part 3: Provisioning & Decommissioning Teams (
New-Team,New-TeamChannel,Add-TeamUser,Remove-Team)