Install the Microsoft Teams PowerShell module
You can install the Microsoft Teams module from the PowerShell Gallery. To install the Microsoft Teams module, run the following command:
Install-Module -Name MicrosoftTeams
The Microsoft Teams module doesn't update automatically. To update the Microsoft Teams module, run the following command:
Update-Module -Name MicrosoftTeams
Connecting to Microsoft Teams
You can connect to Microsoft Teams by using the Connect-MicrosoftTeams cmdlet with no additional parameters. When you connect to Microsoft Teams, you're prompted for a username and password to sign in. You might also be prompted for multifactor authentication. Be sure to sign in with a user account that has sufficient privileges to perform the actions you want to complete.
For automated or unattended scripts, the Connect-MicrosoftTeams cmdlet also supports certificate-based authentication using a service principal. Provide the -CertificateThumbprint, -ApplicationId, and -TenantId parameters to connect without user interaction:
Connect-MicrosoftTeams -CertificateThumbprint "<thumbprint>" -ApplicationId "<app-id>" -TenantId "<tenant-id>"