This week, Microsoft released version 2.0.0 of the Microsoft Teams PowerShell module. This version of the Microsoft Teams PowerShell module no longer includes the New-CsOnlineSession command, which administrators used to connect to Skype for Business Online PowerShell. Administrators can now use the Connect-MicrosoftTeams cmdlet to connect to Microsoft Teams and Skype for Business Online for PowerShell management.

In this post, you will learn some history of the two different PowerShell modules. You will also learn how to update your existing Microsoft Teams PowerShell module to the latest version and connect to your tenant.

History of the Microsoft Teams PowerShell Modules

Last year, Microsoft made improvements to the Microsoft Teams PowerShell module by incorporating the New-CsOnlineSession command. This command came from the Skype for Business Online Windows PowerShell module for connecting to Skype for Business Online.

With the inclusion of the command, administrators no longer needed to download both the Microsoft Teams PowerShell module and the Skype for Business Online Windows PowerShell module. You used the one module to connect to both, although you still had to use two different PowerShell commands to do so.

This improvement also came at the announcement that Microsoft planned to retire the Skype for Business Online Windows PowerShell module. This module is no longer available for download after February 2021. Microsoft will stop accepting remote PowerShell sessions using this module later in 2021.

Release of the New Microsoft Teams PowerShell Module

Version 2.0.0 removes the New-CsOnlineSession command in favor of the single Connect-MicrosoftTeams command. While a welcome improvement, this change requires administrators to eventually update any scripts or automation using the New-CsOnlineSession command (or purposefully use older versions of the module).

If you don’t have an existing installation of the Microsoft Teams PowerShell module, use the Install-Module command to install the module from the PowerShell Gallery.

Install-Module -Name MicrosoftTeams

If you receive a warning about installing from an untrusted repository, select the Yes option to continue. If you receive a warning about requiring administrators rights to install for all users, scope the install to the current user, like this:

Install-Module -Name MicrosoftTeams -Scope CurrentUser

Updating the Microsoft Teams PowerShell Module

Use the Get-Module command to view what version of the module is currently installed. If the module is not currently imported, add the -ListAvailable parameter to your command.

Get-Module -Name MicrosoftTeams -ListAvailable

If you already have the Microsoft Teams PowerShell module installed, use the Update-Module command to install to the latest version. PowerShell will download the latest binaries for the module.

Update-Module -Name MicrosoftTeams
powershell microsoft teams module
Viewing and updating the module version

The module includes more commands formerly found in the Skype for Business Online Windows PowerShell module. These commands are the ones you are probably familiar with that include Cs, CsOnline, or CsTeams. The commands were previously made available when you imported the Skype Online remote PowerShell session but are now part of the module.

microsoft teams powershell commands
Module now include Skype Online commands as functions.

Connecting to Your Teams Tenant

As already mentioned, you now use Connect-MicrosoftTeams to connect to both the Microsoft Teams and Skype for Business Online PowerShell sessions. Let’s take a look at some examples using different versions of PowerShell.

Windows PowerShell 5.1

In Windows PowerShell version 5.1, running Connect-MicrosoftTeams with additional parameters will prompt you to sign in to your account.

powershell connect-microsoftteams
Connecting using Windows PowerShell 5.1

Once connected, PowerShell displays information about the tenant including Account, Environment, Tenant, and TenantId. This output is very similar to the output generated by the Azure AD PowerShell module. Once connected, you can run both Microsoft Teams and former Skype Online PowerShell commands.

powershell connect-microsoftteams
Running both Microsoft Teams and legacy Skype Online commands from single session

To avoid the prompt, save your credentials to a variable using the Get-Credential command. Another window will prompt for the username and password input. Use this variable with the -Credential parameter to make the connection.

$creds = Get-Credential
Connect-MicrosoftTeams -Credentials $creds
powershell get-credential
powershell connect-microsoftteams

PowerShell 7

When running Connect-MicrosoftTeams in PowerShell 7, PowerShell opens a browser to complete the authentication process. Log into your account using your Microsoft Teams administrator username and password.

You can also device authentication by including the UseDeviceAuthentication parameter.

connect-microsoftteams device authentication teams powershell

You navigate to https://microsoft.com/devicelogin and enter the code to authenticate. With the code entered, enter a username and password or select an existing account to log in. Once successfully authenticated, close the browser window and return to the PowerShell console.

powershell device authentication
powershell device authentication

Check out more information about working with PowerShell 7 in Exploring New Functionality in the Microsoft Teams PowerShell Module.

Closing

It is finally nice to see Microsoft consolidating the different modules used to manage Microsoft Teams and provide a single connect command. However, this update requires script writers to account for multiple versions of the module and their respective capabilities.

Questions or comments? If so, drop me a note below or find me on Twitter or LinkedIn to discuss further.

Enjoyed this article? Check out more of my articles on Microsoft Teams by clicking here!