Hello Readers, I hope you’re well.
Just a quick one today. I saw on Twitter that the latest version of the Microsoft Teams PowerShell module, version 2.0 has been released. And while that on it’s own isn’t particularly exciting or newsworthy. There are some changes with this release that are worth noting.
Tiny bit of background first. We all know that the SkypeOnline PowerShell module has now been retired. There was a message centre announcement in December 2020 stating “Administrators can continue to use Skype for Business Online Connector till July 31, 2021 but after Feb 15, 2021 will not be able to download the module.”. They go on to tell you how to install the latest version of the Microsoft Teams PowerShell module and how to move from SkypeOnline to Teams PowerShell modules.
Version 2.0.0 of Teams PowerShell Module is available now for download: PowerShell Gallery | Microsoft Teams 2.0
What’s changed
New features, fixes and changes:
- Use Connect-MicrosoftTeams as the single command to login and manage Teams and Skype for Business online. New-CsOnlineSession is no longer required to login and manage Skype for Business Online.
- This will require a minor update from your side and make changes as documented here.
- No need to use Enable-CsOnlineSessionForReconnection to run long scripts or stay connected.
How to update
First you need to uninstall the SkypeOnline PowerShell module. Follow these steps on how to move from Skype for Business Online Connector to Teams PowerShell module.
After that you only need to install the MicrosoftTeams PowerShell module. In an elevated PowerShell or ISE run teh following. I use Force to update from a previoud version.
Install-Module MicrosoftTeams -Force
How to connect
You can just keep it simple and run
$creds = Get-Credential
Connect-MicrosoftTeams -Credential $creds
This works fine, it just prompts you for your credentials every time you use it.
You can also store the credentials as an excrypted secure string and then call those as your creds variable.
First you need to save your password in a secure format
Read-Host “Enter Password” -AsSecureString | ConvertFrom-SecureString | Out-File “c:\Scripts\Password.txt”
Next you can use the following to store the credentials as a variable to connect to Teams and other PowerShell modules.
$Username = “your.adminuser@domain.com”
$Password = cat “c:\Scripts\password.txt” | ConvertTo-SecureString
$Creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $Password
Next you can connect
Connect-MicrosoftTeams -Credential $Creds
Bring it all together
I use one script to authenticate and connect to Micorosoft Teams, Exchange and Azure AD. Just replace your.adminuser@domain.com with your admin username. And change the location of your Password file
#You need to run this first to save your password as an encrypted file
#Read-Host “Enter Password” -AsSecureString | ConvertFrom-SecureString | Out-File “C:\Scripts\Password.txt”
#Authenticate and connect to a new Microsoft Teams PowerShell session
$Username = “your.adminuser@domain.com”
$Password = cat “c:\Scripts\password.txt” | ConvertTo-SecureString
$Creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $Password
Connect-MicrosoftTeams -Credential $Creds
#Authenticate and connect to a new Exchange Online PowerShell session
Connect-ExchangeOnline -Credential $Creds -ShowProgress $true
#Authenticate and connect to a new Azure AD PowerShell session
Connect-MsolService -Credential $Creds
#Authenticate and connect to Azure AD using the Azure Active Directory PowerShell for Graph module
Connect-AzureAD -Credential $Creds
If you need to connect to more modules, just add them to the script. Connect to all Microsoft 365 services in a single PowerShell window – Microsoft 365 Enterprise | Microsoft Docs
Caveats
If you use MFA, storing the creds won’t work. You’ll get an error if you try.

Once connected to Teams PowerShell, you’ll see that all Teams and CS (communication server/SkypeOnline) commands are available. Don’t believe me? Run the following
get-command -Module MicrosoftTeams | out-file c:\commands.txt
If you run a get-command -Module MicrosoftTeams | measure you get 568 commands

Wrap up
Not having to use new-csonlinesession to get at the SkypeOnline commands is a huge win. This means you get all of the commands you need in a single connection. And because, unlike the SkypeOnline PowerShell module, the Teams PowerShell module sessions stay connected until you close out or disconnect, you can run it all day without disconnects, either just to stay connected and dip in and out to do specific tasks or you can run long scripts for big jobs.
Additional Resources
- Install Microsoft Teams PowerShell – Microsoft Teams | Microsoft Docs
- Move from Skype for Business Online Connector to the Teams PowerShell module – Microsoft Teams | Microsoft Docs
- Connect to all Microsoft 365 services in a single PowerShell window – Microsoft 365 Enterprise | Microsoft Docs
- (Updated) Skype for Business Online Connector retirement
- Announcing Teams PowerShell Module 2.0 Message Centre
Hello Randy Chapman,
Thank you for providing the detailed explanation related to Microsoft Teams Module 2.0.0
I was using SkypeOnlineConnector Module with New-CsOnlineSession to open the new session to run CS commands using parameter -OAuthAccessToken. We are in the process of migrating from SkypeOnlineConnector to Teams Powershell Module.
I have an issue while connecting Microsoft teams with -AadAccessToken. Error details are provided below:
Is there any solution or alternative approach available in Microsoft-Teams Powershell Module to execute CS commands after making connection using Token.
Connect-MicrosoftTeams -AadAccessToken $token -AccountId $acctName
Account Environment Tenant TenantId
——- ———– —— ——–
AzureCloud
PS C:\Users\ensar> Get-CsOnlineUser
Exception calling “GetSteppablePipeline” with “1” argument(s): “Exception calling “GetRemoteNewCsOnlineSession” with “1” argument(s): “Run either Connect-MicrosoftTeams or new-csonlinesession before running cmdlets.””
At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.0.0\net472\SfBORemotePowershellModule.psm1:9474 char:13
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline($myI …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CmdletInvocationException
LikeLike
I’m also getting this issue. Has anyone managed to solve this one? Im wondering if maybe my application that I’m authenticating via does not have appropriate permissions maybe? Any help would be appreciated
LikeLike
There’s an upgrade available to 2.1 which might help. If it does, please let me know
LikeLike
I have tested it with the MicrosoftTeams Module 2.1. Still get the same error as Sumanth Ch.
LikeLike
Still get this error with 2.3.2 pré-release today…
LikeLike