Microsoft Teams has its PowerShell module called ‘MicrosoftTeams’. It helps administrators manage Teams, policies, and their settings through PowerShell.
Install Microsoft Teams PowerShell Module:
To download and install Microsoft Teams PowerShell module, run the following cmdlet in the Windows PowerShell.
Install-Module -Name MicrosoftTeams
After installing, you need to import the Microsoft Teams module to avoid the following error: ‘Connect-MicrosoftTeams is not recognized as the name of a cmdlet’.
To import the module, execute the below cmdlet.
Import-Module –Name MicrosoftTeams
Connect to Microsoft Teams PowerShell:
The ‘Connect-MicrosoftTeams’ cmdlet creates PowerShell session to Microsoft Teams environment. To create a session, run the cmdlet as shown below.
You can also use the above cmdlet to connect to Microsoft Teams with MFA enabled accounts.
To run the cmdlet by using the Credential parameter, you can use the following cmdlet.
$Cred=Get-Credential Connect-MicrosoftTeams –Credential $Cred
After connecting to the Teams, you can make use of the Microsoft Teams PowerShell commands like Get-Team, Get-TeamChannel, Get-TeamUser, and more, to view and gain insights about the Teams, channels, its members in your M365 environment.
To get a list of all the cmdlets available in the Microsoft Teams module, run the following cmdlet.
Get-Command –Module MicrosoftTeams
Note: You can manage Get-Cs*, Set-Cs*, New-Cs* cmdlets from the Microsoft Teams module itself. You do not require Skype for Business Online Connector for Teams administration.
To disconnect PowerShell from the Microsoft Teams environment, you can execute the below cmdlet.
If you are working with multiple Office 365 workloads such as Azure AD, Exchange Online, SharePoint Online, etc., download the connect to all Office 365 services PowerShell script. It helps to connect all the Office 365 services by using a single cmdlet.