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

6,775

Solution 1

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.

Solution 2

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

Share:
6,775
MacroPower
Author by

MacroPower

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Updated on September 18, 2022

Comments

  • MacroPower
    MacroPower almost 2 years

    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.

  • Net Runner
    Net Runner almost 7 years
    Yeah, the coworker of mine faced the same issue a few days ago. And these steps fixed the problem.
  • MacroPower
    MacroPower almost 7 years
    So I think you almost got it. I took a look at the -SessionOption param to see if I could try using non-SSL for testing. I ended up finding another script github.com/pecigonzalo/Oh-My-Posh/blob/master/plugins/o365/… That used that param to define proxy settings. That fixed my problem 100%. If you edit your answer to include this I will accept it. :) Thank you!
  • Grigory Sergeev
    Grigory Sergeev almost 7 years
    @MacroPower glad to be of help. By the way, what kind of proxy do you have and which parameter have you used with proxyoption? I have tried IEConfig out of curiosity and that broke my connection, trying to look for script URL that doesn't exist (we used to have a proxy script back in a daym, but currently IE displays autodetect, not autoconfigure from url)
  • MacroPower
    MacroPower almost 7 years
    It's some type of Websense Content Filter, possibly in conjunction with some other unknown wizardry. I wish I had more information but the proxy servers aren't part of my department.