This article explains how to connect to Skype for Business Online with PowerShell, using an account that has been enabled for MFA.
Prerequisites
You need to be a Global Administrator in the Office 365 Tenant, or at the least be assigned to the Skype for Business administrator role.
You need to be using a 64-bit version of one of the following Windows OS:
- Windows 10
- Windows 8 or 8.1
- Windows 7 SP1
- Windows Server 2016
- Windows Server 2012 R2
- Windows Server 2012
- Windows Server 2008 R2 SP1
The computer also must be running:
- PowerShell
- Skype for Business Online Connector module
Download the latest version of the Skype for Business Online Connector module (click here). Run through the installer.
Connect to Skype for Business Online
Run the following PowerShell to import the Skype for Business Online module:
Import-Module SkypeOnlineConnector
When the module has been imported, run the following command:
$sfbSession = New-CsOnlineSession
Enter the UPN of your Azure AD account when prompted.
Enter your password when prompted. Click Sign in.
MFA in this example is via a SMS message. Enter the code, click Verify.
Although a connection has been established to the Skype for Business Online tenant, it’s necessary to run the following command to download scripts, cmdlets, etc. to manage Skype for Business Online:
Import-PSSession $sfbSession
Close the Connection
When you’re done, closing the PowerShell window will leave the remote connection to Skype for Business Online active for the next 15 minutes. It’s good practice to end the session when you’re done.
Remove-PSSession $sfbSession
If you end up coming across this page as a result of the following error, you need to install the latest Skype for Business Online connector module (follow the blog).
New-CsOnlineSession
cmdlet New-CsOnlineSession at command pipeline position 1
Supply values for the following parameters:
Credential
Get-CsWebTicket : Failed to logon with given credentials. Make sure correct user name and password provided.
At C:\Program Files\Common Files\Skype for Business
Online\Modules\SkypeOnlineConnector\SkypeOnlineConnectorStartup.psm1:107 char:18
+ … webticket = Get-CsWebTicket -TargetServer $TargetServer -Credential $ …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-CsWebTicket], CommonAuthException
+ FullyQualifiedErrorId : Microsoft.Rtc.Admin.Authentication.CommonAuthException,Microsoft.Rtc.Management.OnlineCo
nnector.GetWebTicketCmdlet
LikeLike
Please also note the complete command to import when following this guide should be:
Import-PSSession $sfbSession
LikeLike
Thanks for spotting the error Martin, I have corrected the PowerShell command.
LikeLike