locked
Invoke-WebRequest error RRS feed

  • Question

  • I got the error when trying to run Invoke-WebRequest as below. Is there a workaround?

    Invoke-WebRequest -Uri 'https://web.tmxmoney.com'
    Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
    At line:1 char:1
    + Invoke-WebRequest -Uri 'https://web.tmxmoney.com'
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
        + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
     

    Sunday, September 16, 2018 9:19 PM

Answers

  • [Net.ServicePointManager]::SecurityProtocol +='tls12'
    Invoke-WebRequest -Uri 'https://web.tmxmoney.com'

    \_(ツ)_/

    • Marked as answer by Ian3 Monday, September 17, 2018 8:52 PM
    Sunday, September 16, 2018 9:43 PM
  • Hi,

    Thanks for your question.

     About the parameter "-SkipCertificateCheck", it is added in PowerShell V6.0. So you should check the version of your PowerShell. Try to run "$PSVersionTable" to get it.

    Best Regards,

    Lee


    Just do it.

    • Marked as answer by Ian3 Monday, September 17, 2018 8:52 PM
    Monday, September 17, 2018 6:44 AM

All replies

  • [Net.ServicePointManager]::SecurityProtocol +='tls12'
    Invoke-WebRequest -Uri 'https://web.tmxmoney.com'

    \_(ツ)_/

    • Marked as answer by Ian3 Monday, September 17, 2018 8:52 PM
    Sunday, September 16, 2018 9:43 PM
  • Thanks. It works but when run it, it pops up a Security Alert window and saying 'the identity of this web site or the integrity of this connection cannot be verified'. I tried to use -SkipCertificateCheck to bypass it but got error:

    Invoke-WebRequest -Uri 'https://web.tmxmoney.com' -SkipCertificateCheck
    Invoke-WebRequest : A parameter cannot be found that matches parameter name 'SkipCertificateCheck'.
    At line:1 char:51
    + ... voke-WebRequest -Uri 'https://web.tmxmoney.com' -SkipCertificateCheck
    +                                                     ~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

    Sunday, September 16, 2018 10:52 PM
  • Always start with eh help to learn how to use a command.  Check all of the parameters for usage.

    help Invoke-WebRequest -full


    \_(ツ)_/

    Sunday, September 16, 2018 11:27 PM
  • Hi,

    Thanks for your question.

     About the parameter "-SkipCertificateCheck", it is added in PowerShell V6.0. So you should check the version of your PowerShell. Try to run "$PSVersionTable" to get it.

    Best Regards,

    Lee


    Just do it.

    • Marked as answer by Ian3 Monday, September 17, 2018 8:52 PM
    Monday, September 17, 2018 6:44 AM
  • Hi, 

    I tried to add the parameter"-SkipCertificateCheck" with PowerShell v6 but I get the error below. Note that I run Powershell as administrator with no blockervar.

    Do you have any idea to resolve this issue ? 


    $uri = "https://www.leboncoin.fr/recherche/?category=10&regions=12&location=Paris"
    Invoke-WebRequest -Uri $uri -SkipCertificateCheck

    Invoke-WebRequest :
    You have been blocked#cmsg{animation: A 1.5s;}@keyframes A{0%{opacity:0;}99%{opacity:0;}100%{opacity:1;}}Please enable JS and disable any ad blockervar dd={'cid':'AHrlqAAAAAMASs8KEc-_IPsAXRaR8Q==','hsh':'05B30BD9055986BD2EE8F5A199D973'}

    Thank you :)

    Sunday, December 23, 2018 1:50 PM
  • Please do not add unrelated questions to another users topic.


    \_(ツ)_/

    Sunday, December 23, 2018 2:02 PM