Microsoft Teams PowerShell
The MicrosoftTeams module: teams, policies, voice and meeting settings.
Official documentation- You must call the Connect-MicrosoftTeams cmdlet before calling any other cmdlets.Get-Team, New-Team and the other team cmdlets fail with this message when the MicrosoftTeams module has no session. Run Connect-MicrosoftTeams, then retry.
- New-Team -Visibility: The argument does not belong to the set "Public,Private,HiddenMembership"New-Team -Visibility accepts only Public, Private or HiddenMembership. Values such as Org, Internal or Hidden fail validation before any call to Teams is made.
- Session is not established, run Connect-MicrosoftTeams before requesting access tokenThe Cs cmdlets of the MicrosoftTeams module (Get-CsOnlineUser, Grant-Cs*Policy, Set-CsPhoneNumberAssignment) need a session. Run Connect-MicrosoftTeams first.
- Cannot process command because of one or more missing mandatory parameters: NumberType (Teams phone)Assigning a Teams phone number needs -Identity, -TelephoneNumber and -NumberType (DirectRouting, CallingPlan or OperatorConnect); without the type it fails.
- Connect-MicrosoftTeams: interactive, device code and certificate (app-only) sign-inConnect-MicrosoftTeams signs in to Teams PowerShell. Use -UseDeviceAuthentication without a browser, or -Certificate, -ApplicationId and -TenantId for app-only.
- Get-Team and New-Team: list and create Microsoft Teams teams with PowerShellGet-Team filters teams by name, user, visibility or archive state; New-Team creates one with -Visibility Public, Private or HiddenMembership. Add members too.
- Grant-CsTeamsMeetingPolicy: assign a Teams policy to a user, a group, many users or the whole tenantGrant-CsTeamsMeetingPolicy -Identity assigns to one user, -Group to a group with a rank, -Global to everyone. For thousands of users use a batch assignment.
- Set-CsTeamsMessagingPolicy: change Teams chat settings (edit, delete, Giphy, read receipts)Set-CsTeamsMessagingPolicy -Identity Global changes the org-wide chat settings; create a custom policy with New-CsTeamsMessagingPolicy and assign it with Grant.
- Add-TeamUser -Role Owner: add an owner (or member) to a Microsoft TeamAdd-TeamUser -Role Owner adds a team owner; without -Role the user is a Member. ValidateSet values checked offline, demoting with Remove-TeamUser -Role Owner.
- Connect-MicrosoftTeams -TeamsEnvironmentName: TeamsGCCH, TeamsDOD, TeamsChinaConnect-MicrosoftTeams -TeamsEnvironmentName TeamsGCCH, TeamsDOD or TeamsChina connects to a sovereign cloud. GCC and commercial tenants should not use it.
- Connect-MicrosoftTeams -UseDeviceAuthentication: sign in with a device codeConnect-MicrosoftTeams -UseDeviceAuthentication signs in with a device code from any browser. Works in Windows PowerShell 5.1 too; parameter set and limits.
- Get-CsOnlineUser -Filter: find Teams users by policy, phone number or account typeGet-CsOnlineUser -Filter finds Teams users by policy, LineURI, feature type or account type on the server. Syntax, quoting, examples and filter limitations.