The MicrosoftTeams module manages teams, channels, policies (meetings, messaging, apps, channels) and telephony. For Teams administration at scale it is indispensable: you do not assign a policy to a hundred users with the mouse. The module works in Windows PowerShell 5.1 and PowerShell 7; we recommend PowerShell 7.
Installing and updating
Install-Module MicrosoftTeams -Scope CurrentUser
Get-Module MicrosoftTeams -ListAvailable | Select-Object Name, Version
Update-Module MicrosoftTeamsMicrosoft ships new versions often and new policy settings only appear in the latest. Missing a parameter that the documentation mentions? Update first.
Connecting interactively
Connect-MicrosoftTeams
Get-Team -User [email protected] | Select-Object DisplayName, GroupIdA sign-in window opens with MFA. Most policy changes need the Teams Administrator role.
Common tasks
# Owners and members of a team
Get-TeamUser -GroupId <group id> | Sort-Object Role
# Add an owner
Add-TeamUser -GroupId <group id> -User [email protected] -Role Owner
# Which meeting policy does a user have?
Get-CsOnlineUser -Identity [email protected] | Select-Object TeamsMeetingPolicy
# Assign a policy to everyone in a group
New-CsGroupPolicyAssignment -GroupId <group id> -PolicyType TeamsMeetingPolicy -PolicyName 'Extern-beperkt' -Rank 1Assigning a policy through a group is easier to maintain than per user: new staff get it automatically when they join the group.
Unattended: app-only with a certificate
For scheduled scripts, register your own app in Entra ID, give it the required Graph permissions and a Teams admin role, and attach a certificate:
Connect-MicrosoftTeams -TenantId <tenant id> -ApplicationId <client id> -CertificateThumbprint <thumbprint>In Azure Automation, recent versions also support a managed identity with Connect-MicrosoftTeams -Identity.
Not every cmdlet works app-only. Most Cs policy cmdlets do, but some team and user cmdlets need a user context. So test your script in the mode it will run in, not only interactively.
Known issues
- Change not visible straight away: policies take time to apply, sometimes a few hours. Check the assignment with
Get-CsOnlineUserand wait. The term 'Get-CsOnlineUser' is not recognized: you are not connected or an old version is loaded. Reconnect and checkGet-Module MicrosoftTeams.- Several versions: see Cleaning up PowerShell modules.
Disconnect-MicrosoftTeamsFurther reading: Change channel layout with PowerShell and Teams channels: Posts vs Threads.
Frequent errors and how to fix them
These are the messages people type into search when the module will not start. The exact wording is here so this page can be found.
The term 'Connect-MicrosoftTeams' is not recognized- MicrosoftTeams module missing. Install-Module MicrosoftTeams; new window; Import-Module MicrosoftTeams.
AADSTS / consent / MFA- Teams cmdlets need a Teams admin role, or app-only with the right Graph/Skype permissions.
Assembly / version conflict- Multiple MicrosoftTeams versions. Uninstall-Module MicrosoftTeams -AllVersions, then install one current version.
A parameter cannot be found that matches parameter name 'ThreadedChannelCreation'- MicrosoftTeams module too old. 7.1 or later in PowerShell 7. Cmdlet is Set-CsTeamsChannelsPolicy (Channels, plural).
layoutType / Invalid request- Graph scope ChannelSettings.ReadWrite.All missing, or the client does not expose layoutType yet. PATCH with Invoke-MgGraphRequest.
Questions about this, or need help setting it up? We are happy to think along.
Message on LinkedIn →