locked
Issues Submitting Login Form RRS feed

  • Question

  • Hi guys

    I've decided to learn Powershell for an ETL workflow but I'm having trouble with the basics.

    I receive the below error when attempting to Invoke-WebRequest:

    [ERROR] Invoke-WebRequest : The remote name could not be resolved: 'logon'

    Below is my script:

    $sTarget = "http://www.lcbo.com/webapp/wcs/stores/servlet/en/sod/" $sLogin = "redacted" $sPassword = "redacted" function Main() { Write-Host "Logging into $sTarget" $htmlTargetLogin = Invoke-WebRequest $sTarget -SessionVariable session $htmlTargetLogin.Forms[0].fields["logonId"] = $sLogin $htmlTargetLogin.Forms[0].fields["logonPassword"] = $sPassword

    $htmlTargetMain = Invoke-WebRequest $htmlTargetLogin.Forms[0].Action -WebSession $session -Body $htmlTargetLogin -Method Post return } Main

    Any suggestions?

    Thanks!
    Simon

    • Moved by Bill_Stewart Tuesday, July 12, 2016 9:54 PM Off-topic
    Saturday, June 11, 2016 3:23 PM

All replies

  • I see no Workflow here.  It is just a function.

    \_(ツ)_/

    Saturday, June 11, 2016 4:35 PM
  • The second call should look like this:

    Invoke-WebRequest $starget -WebSession $session -Body $htmlTargetLogin -Method Post

    The first call creates the SessionVariable  Further calls apply the session variable with WebSession.


    \_(ツ)_/

    Saturday, June 11, 2016 4:40 PM