locked
Powershell connect skype for business online error RRS feed

  • Question

  • Hello ,

    I am connecting to skype for business online through powershell, its working fine and getting connected.Below is the command i am using.

    import-Module LyncOnlineConnector
    $MyClearTextUsername="test@use36.onmicrosoft.com"
    $MyClearTextPassword="******"
    $SecurePassword=Convertto-SecureString –String $MyClearTextPassword –AsPlainText –force
    $MyCredentials=New-object System.Management.Automation.PSCredential $MyClearTextUsername,$SecurePassword
    $sfbSession = New-CsOnlineSession -Credential $MyCredentials
    Import-PSSession $sfbSession -AllowClobber/

    But when i am using a c# program code to connect using the above  powershell commands, it gives the below error.

    "System.Management.Automation.CmdletInvocationException: Unable to connect to the remote server ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 52.113.67.78:80
       at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
       at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
       --- End of inner exception stack trace ---
       at Microsoft.Rtc.Management.Common.AutoDiscoverClient.QueryAutoDiscoverService(String queryUrl)
       at Microsoft.Rtc.Management.Common.AutoDiscoverClient.DiscoverUrl(String autodiscoverEndpoint, String desiredLink, Int32 numOfHops)
       at Microsoft.Rtc.Management.Common.AutoDiscoverClient.DiscoverUrlForDomain(String discoveryServiceUrl, String domainToken, String desiredLink)
       at Microsoft.Rtc.Management.OnlineConnector.GetPowerShellEndpointCmdlet.BeginProcessing()
       at System.Management.Automation.Cmdlet.DoBeginProcessing()
       at System.Management.Automation.CommandProcessorBase.DoBegin()
       --- End of inner exception stack trace ---
       at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
       at System.Management.Automation.Runspaces.Pipeline.Invoke()
       at FimSync_Ezma.EzmaExtension.RunScript(String scriptText) in E:\source code - Copy\Office365MA\Office365MA.cs:line 135
       at FimSync_Ezma.EzmaExtension.OpenImportConnection(KeyedCollection`2 configParameters, Schema types, OpenImportConnectionRunStep importRunStep) in E:\source code - Copy\Office365MA\Office365MA.cs:line 177
    Forefront Identity Manager 4.1.3646.0"
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="FIMSynchronizationService" />
        <EventID Qualifiers="49152">6801</EventID>
        <Level>2</Level>
        <Task>3</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2018-12-25T17:58:16.000000000Z" />
        <EventRecordID>41168200</EventRecordID>
        <Channel>Application</Channel>
        <Computer>VC01-F102-FIMDV.FIMTEST.COM</Computer>
        <Security />
      </System>
      <EventData>
        <Data>System.Management.Automation.CmdletInvocationException: Unable to connect to the remote server ---&gt; System.Net.WebException: Unable to connect to the remote server ---&gt; System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 52.113.67.78:80
       at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
       at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket&amp; socket, IPAddress&amp; address, ConnectSocketState state, IAsyncResult asyncResult, Exception&amp; exception)
       --- End of inner exception stack trace ---
       at Microsoft.Rtc.Management.Common.AutoDiscoverClient.QueryAutoDiscoverService(String queryUrl)
       at Microsoft.Rtc.Management.Common.AutoDiscoverClient.DiscoverUrl(String autodiscoverEndpoint, String desiredLink, Int32 numOfHops)
       at Microsoft.Rtc.Management.Common.AutoDiscoverClient.DiscoverUrlForDomain(String discoveryServiceUrl, String domainToken, String desiredLink)
       at Microsoft.Rtc.Management.OnlineConnector.GetPowerShellEndpointCmdlet.BeginProcessing()
       at System.Management.Automation.Cmdlet.DoBeginProcessing()
       at System.Management.Automation.CommandProcessorBase.DoBegin()
       --- End of inner exception stack trace ---
       at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
       at System.Management.Automation.Runspaces.Pipeline.Invoke()
       at FimSync_Ezma.EzmaExtension.RunScript(String scriptText) in E:\source code - Copy\Office365MA\Office365MA.cs:line 135
       at FimSync_Ezma.EzmaExtension.OpenImportConnection(KeyedCollection`2 configParameters, Schema types, OpenImportConnectionRunStep importRunStep) in E:\source code - Copy\Office365MA\Office365MA.cs:line 177
    Forefront Identity Manager 4.1.3646.0</Data>
      </EventData>
    </Event>

    Why there are issues in remote connection from the C# code and not the powershell?

    How to resolve the issue?

    Regards,

    Shakti

    Wednesday, December 26, 2018 7:21 PM

All replies

  • Hi Shakti,

    Would you please verify if the URL you are making for C# code is correct or not, then check in the browser to see if it is browsing?

    And based on your description, this issue is more related with C# codes itself, we would highly recommend you to ask in a dedicated Skype for Business on Stack Overflow under Skype Dev center.

    Thanks for understanding! :)

    Kind regards,

    Calvin Liu


    Please remember to mark the reply as an answer if you find it is helpful. It will assist others who has similar issue. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • Proposed as answer by Calvin-Liu Monday, December 31, 2018 9:56 AM
    Thursday, December 27, 2018 9:21 AM