ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Solved Invoke-WebRequest sometimes fails to connect to https

    IT Discussion
    powershell invoke-webrequest
    3
    7
    1.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JaredBuschJ
      JaredBusch
      last edited by JaredBusch

      So I am trying to push out my MeshCentral agent via ScreenConnect's command function.

      Well it works on some computer, but not others.

      I'm getting hit by

      Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel. 
      

      It works on some computers but not on others.

      Command being used:

      #!ps
      #maxlength=100000
      #timeout=90000
      $url_client_a = 'https://mc.bundystl.com/meshagents?id=4&meshid=>snip<&installflags=0'
      Invoke-WebRequest -OutFile c:\meshagent.exe $url_client_a
      

      Edit: This is the workign command:

      #!ps
      #maxlength=100000
      #timeout=90000
      [Net.ServicePointManager]::SecurityProtocol = "tls12"
      $url_client_a = 'https://mc.bundystl.com/meshagents?id=4&meshid=>snip<&installflags=0'
      Invoke-WebRequest -OutFile c:\meshagent.exe $url_client_a
      
      1 Reply Last reply Reply Quote 3
      • M
        manxam
        last edited by

        @JaredBusch said in Invoke-WebRequest sometimes fails to connect to https:

        The request was aborted: Could not create SSL/TLS secure channel.

        Could this be a TLS issue? Perhaps the version of PowerShell on one computer is using TLS1 and the others are using TLS1.2?

        Your site appears to support 1.2 and 1.3 only so perhaps the following added to your PS script before the WebRequest will work:

        [Net.ServicePointManager]::SecurityProtocol = "tls12"
        
        JaredBuschJ 1 Reply Last reply Reply Quote 5
        • JaredBuschJ
          JaredBusch @manxam
          last edited by

          @manxam said in Invoke-WebRequest sometimes fails to connect to https:

          @JaredBusch said in Invoke-WebRequest sometimes fails to connect to https:

          The request was aborted: Could not create SSL/TLS secure channel.

          Could this be a TLS issue? Perhaps the version of PowerShell on one computer is using TLS1 and the others are using TLS1.2?

          Your site appears to support 1.2 and 1.3 only so perhaps the following added to your PS script before the WebRequest will work:

          [Net.ServicePointManager]::SecurityProtocol = "tls12"
          

          That did it for one system. let me test a couple others.

          1 Reply Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch
            last edited by

            worked on all the ones i tested that had failed.

            M 1 Reply Last reply Reply Quote 0
            • DashrenderD
              Dashrender
              last edited by

              Please update the OP with the new command.

              Thanks.

              JaredBuschJ 1 Reply Last reply Reply Quote 0
              • JaredBuschJ
                JaredBusch @Dashrender
                last edited by

                @Dashrender said in Invoke-WebRequest sometimes fails to connect to https:

                Please update the OP with the new command.

                Thanks.

                updated

                1 Reply Last reply Reply Quote 0
                • M
                  manxam @JaredBusch
                  last edited by

                  @JaredBusch : Awesome! Glad to hear it worked for you...

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post