locked
Logon to Website with Invoke-WebRequest RRS feed

  • Question

  • Hi, I need help, as I am tying to logon to XING with Invoke-Webrequest. I dont get an error, but it does not work.
     
    $loginURL = "https://login.xing.com"
    
    $req = Invoke-WebRequest $loginURL -SessionVariable Xing
    
    $form = $req.Forms[0]
    $form.fields["login_form_username"] = $username
    $form.fields["login_form_password"] = $password
    $req = Invoke-WebRequest $form.Action -WebSession $Xing -Method POST -Body $form.Fields

    Thanks!

    • Edited by RobertWe Monday, September 24, 2018 4:57 PM
    Monday, September 24, 2018 4:55 PM

All replies

  • You have to do it like this:

    $userlogin = $form.getElementsByTagName('input')|?{$_.ID -eq 'login_form_username'}
    $userlogin.Value = $username

    or:

    $webrequest..ParsedHtml.getElementById('login_form_username')


    \_(ツ)_/



    • Edited by jrv Monday, September 24, 2018 6:20 PM
    Monday, September 24, 2018 6:16 PM
  • But assigning the values work, seems the post action does not.
    • Edited by RobertWe Monday, September 24, 2018 7:10 PM
    Monday, September 24, 2018 7:10 PM