Unable to connect to Skype Online for Business - "winrm" issues

I am attempting to manage Skype Online for Business via the LyncOnlineConnector PowerShell module. I have had no trouble whatsoever connecting to remote exchange. However, I am now trying to do the exact same thing using New-CsOnlineSession rather than New-PSSession (used to connect to o365).

Importing the lync connector works fine. However, when I try to build the session (verbose):

VERBOSE: Determining domain to admin
VERBOSE: AdminDomain = 'x.com'
VERBOSE: Discovering PowerShell endpoint URI
VERBOSE: TargetUri = 'https://admin1a.online.lync.com/OcsPowershellOAuth'
VERBOSE: GET https://admin1a.online.lync.com/OcsPowershellOAuth with 0-byte payload
VERBOSE: AuthUri = 'https://login.windows.net/common/oauth2/authorize'
VERBOSE: Requesting authentication token
VERBOSE: Success
VERBOSE: Initializing remote session
New-PSSession : [admin1a.online.lync.com] Connecting to remote server admin1a.online.lync.com failed with the
following error message : The client cannot connect to the destination specified in the request. Verify that the
service on the destination is running and is accepting requests. Consult the logs and documentation for the
WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service,
run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more
information, see the about_Remote_Troubleshooting Help topic.
At C:\Program Files\Common Files\Skype for Business
Online\Modules\SkypeOnlineConnector\SkypeOnlineConnectorStartup.psm1:147 char:16
+     $session = New-PSSession -ConnectionUri $ConnectionUri.Uri -Credential $cred ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
   gTransportException
    + FullyQualifiedErrorId : CannotConnect,PSSessionOpenFailed

What perplexes me is that I had this same issue with exchange initially, however setting the execution policy (remote force) and running winrm quickconfig seemed to fix everything.

I've tried every suggestion related to winrm I can find, but nothing seems to change this error. I've opened ports, run the command as different users / admin, recreated the session often, ran the commands here, as well as numerous other things from the 'net that I can't remember anymore. Nothing changes my results at all.


First of all, this is the method that gets me connected without any additional settings, except having S4B Online Windows PowerShell Module v6.0.9276 installed.

This is the quote from a short guide on Technet

$sfboSession = New-CsOnlineSession -Credential $credential
Import-PSSession $sfboSession

this gets me connected without error:

PowerShell connected to Skype for Business Online

By the looks of it, it might be network packet inspection or SSL proxy breaking SSL (as it did on Cisco ASAs with SMTP inspection turned on, ruining Exchange TLS connections).

New-CsOnlineSession can be be run with -SessionOption parameter to supply proxy settings information. Configure session with proxy settings inherited from system configuration:

$proxysettings = New-PSSessionOption -ProxyAccessType WinHttpConfig
New-CsOnlineSession -Credential $credential -SessionOption $proxysettings
Import-PSSession $sfboSession

There are more proxy options, including authentication mechanisms and credentials, for New-PSSessionOption cmdlet.


Our Exchange admin tried on a VM and got the same error. But it works fine on his workstation when he’s remotely connected to our network using Direct Access. That pointed to the network issue.

He found out that the firewall was blocking it and we got it to work with this:

$proxysettings = New-PSSessionOption -ProxyAccessType AutoDetect

New-CsOnlineSession -SessionOption $proxysettings