🔧 New: User Management Graph PowerShell Toolkit

Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.

🚀 Launch Toolkit

How to Manage Microsoft Teams Using PowerShell?

Microsoft Teams has become a cornerstone of modern workplace collaboration. While the Microsoft Teams Admin Center provides a graphical interface for management, PowerShell empowers administrators to automate repetitive tasks, generate reports, and handle complex bulk operations efficiently. Whether you're a seasoned admin or just getting started, managing Teams with PowerShell can save time, reduce human error, and help scale operations with precision.


Why Manage Microsoft Teams Using PowerShell?

PowerShell brings tremendous advantages to Teams administration:

  • Automation: Schedule tasks like creating teams, adding users, or exporting reports.
  • Speed: Perform actions faster compared to using the GUI.
  • Bulk Management: Easily handle hundreds of teams or users via scripts and CSVs.
  • Reporting: Extract detailed data for audits or analysis.
  • Reduced Errors: Remove the chance of manual misclicks and typos with consistent scripts.
  • Remote Management: Manage Teams from anywhere without logging into the admin center.

If you're managing a large or dynamic Microsoft 365 environment, PowerShell becomes an essential tool in your arsenal.


Key PowerShell Commands for Teams Administration

The following table lists core Microsoft Teams PowerShell cmdlets using the Microsoft Graph module, with purpose and example usage.


Cmdlet Purpose Example Usage
Get-MgTeam List all Microsoft Teams in the organization Get-MgTeam -All
New-MgTeam Create a new Microsoft Team $team = @{ DisplayName = "Team Name" Description = "This is a sample team" Visibility = "Public" "template@odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('standard')" }New-MgTeam -BodyParameter $team
Update-MgTeam Modify team settings like messaging and permissions $params = @{ memberSettings = @{ allowCreateUpdateChannels = $true } messagingSettings = @{ allowUserEditMessages = $true; allowUserDeleteMessages = $true } funSettings = @{ allowGiphy = $true; giphyContentRating = "strict" } }$teamId = "your-team-id"Update-MgTeam -TeamId $teamId -BodyParameter $params
Get-MgTeamMember Get all members of a specified team $teamId = "9f47ec97-db44-41db-8867-3793cff0a49a"$teamMembers = Get-MgTeamMember -TeamId $teamId -All$teamMemberDetails = foreach ($member in $teamMembers) { $additionalProps = $member.AdditionalProperties $userId = $additionalProps["userId"] if ($userId -ne $null -and $userId -ne "") { $user = Get-MgUser -UserId $userId [PSCustomObject]@{ Id = $user.Id DisplayName = $user.DisplayName UserPrincipalName = $user.UserPrincipalName } } }`$teamMemberDetails
New-MgTeamMember Add a new member or owner to a team $params = @{ "@odata.type" = "#microsoft.graph.aadUserConversationMember" roles = @("owner") "user@odata.bind" = "https://graph.microsoft.com/v1.0/users('8b081ef6-4792-4def-b2c9-c363a1bf41d5')" }New-MgTeamMember -TeamId "72a1f6b2-5829-4f26-b3a4-738b4848e248" -BodyParameter $params
Remove-MgTeamMember Remove a member from a team Remove-MgTeamMember -TeamId -ConversationMemberId
Get-MgTeamChannel List all channels within a team Get-MgTeamChannel -TeamId "4a6c54df-9235-4854-8b98-5c0045c02855"
New-MgTeamChannel Create a new channel in a team $params = @{ displayName = "Architecture Discussion" description = "This channel is where we debate all future architecture plans" membershipType = "standard" }New-MgTeamChannel -TeamId $teamId -BodyParameter $params
Update-MgTeamChannel Rename or update channel description $params = @{ displayName = "Project Updates" }Update-MgTeamChannel -TeamId "12345abc" -ChannelId "54321xyz" -BodyParameter $params
Remove-MgTeamChannel Delete a channel from a team Remove-MgTeamChannel -TeamId "00000000-0000-0000-0000-000000000000" -ChannelId "19:12345678abcdefg@thread.tacv2"

Note: Use Remove-MgGroup to delete a Team as Remove-MgTeam may not work. This is because Teams is essentially backed by Microsoft 365 Groups.


Real-World Example: Bulk Import Users to Microsoft Teams

Bulk-adding users to a team or M365 group can be streamlined with PowerShell using a CSV file.

CSV File Format

DirectoryObjectId
0c96a46b-df04-4b05-b038-083b5058531b
0c96a46b-df04-4b05-b038-083b5058531b
0c96a46b-df04-4b05-b038-083b5058531b

PowerShell Script

Import-CSV "path_to_CSV_file" | ForEach {
    try{
        # Attempt to add a new group member
        $newMember = New-MgGroupMember -GroupId "0097f95d-63b4-48c5-a0ca-310578e2cfdb" -DirectoryObjectId $_.UserID
        #Output success message to the console
        Write-Output "Successfully added user with ID ($_.UserID)"
    }catch{
        # Output error message to the console
        Write-Output "Failed to add user with ID $($_.UserID) to group. Error: $_"
    }
}
                                        

This script ensures large batches of users are added with proper error handling.

Note: Read Microsoft Teams Bulk User Import to understand how the script works. .


Troubleshooting Common PowerShell Issues

Error Cause Solution
Module not found Graph module not installed Run: Install-Module Microsoft.Graph -Scope CurrentUser
Access Denied Insufficient permissions Ensure the app has required Graph API permissions and re-authenticate
Invalid URI / Bad Request Incorrect parameter or malformed body Validate TeamId, ChannelId, and JSON structure in -BodyParameter
Null or empty output Missing -All parameter or scoping issue Use -All with list cmdlets to retrieve complete data
Throttling Too many API calls in a short period Add delay (Start-Sleep -Seconds 3) between requests or implement batching

Conclusion

PowerShell gives IT admins a powerful and flexible way to manage Microsoft Teams. From creating teams to automating membership and reporting, these cmdlets open up endless possibilities for smarter administration. By integrating scripting into your regular workflows, you can significantly boost productivity and streamline collaboration at scale.

Start small, automate frequently used tasks, and gradually expand your Teams PowerShell toolkit for complete control!

Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.

Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.

© Your Site Name. All Rights Reserved. Design by HTML Codex