• Eric Marsi

Connecting to Microsoft Teams & Skype for Business Online via PowerShell using the new Teams Module

Updated: Mar 30



If you have not done so already, check out my guide on installing the latest Microsoft Teams PowerShell Module by CLICKING HERE. This guide will cover the command blocks that are needed to connect to Microsoft Teams and Skype for Business Online via PowerShell.


Features

  • The -OverrideAdminDomain switch is no longer needed

  • The need for a *.onmicrosoft.com account without the -OverrideAdminDomain switch is no longer needed

  • The sessions no longer time out after 15-30 minutes and from my testing has lasted about 48 hours. This means that the Enable-CsOnlineSessionForReconnection cmdlet is no longer needed!

  • There is still a session limit of 3 sessions (Thanks Dimitri Meeuws!)

  • If using this in a script, you can disconnect from Teams Online PS via the Disconnect-MicrosoftTeams cmdlet instead of the old Remove-PSSession cmdlet


Important Note!

It is recommended to occasionally update the Microsoft Teams PowerShell Module with the following command:


Update-Module MicrosoftTeams


Connecting with Modern Auth

For most use cases, Modern Auth is the preferred method as it supports accounts with Multi-Factor Authentication (MFA) and tenants that use Modern Auth. The only down-side is for scripts that run for an extended period of time as they will time out and there is no way to store the credentials in a credential variable.


Run the following commands in a PowerShell console or script:


Import-Module MicrosoftTeams

Connect-MicrosoftTeams


When these cmdlets are issued, you will see the following login prompt:


Note: Basic auth cmdlets are still there with the -Credential switch, but I am no longer able to use this method in a tenant that does not have modern auth enabled.

Congratulations! You are now connected to Microsoft Teams and Skype for Business Online via PowerShell!

722 views2 comments