Share via

invoke-webRequest not working

asif ahamed 201 Reputation points
2023-04-30T04:53:31.0233333+00:00

when I go test.htm file I get this

User name: * Required

Password: * Required

Can someone help me please. I send the user name and password via form.fields (see below)

$response = Invoke-WebRequest -Uri 'https://booking.mylab.com/llbooking/' -SessionVariable rb
$form = $response.Forms[0]
$form.Fields.ctl00_MainContent_LoginView1_Login1_UserName='John.Doe'
$form.Fields.ctl00_MainContent_LoginView1_Login1_Password='Test123'
$form.Fields.ctl00_MainContent_LoginView1_Login1_LoginButton='SIGN IN'
$response = Invoke-WebRequest -Uri 'https://booking.mylab.com/llbooking/' -WebSession $rb -Method POST -Body $form.fields
$response.RawContent | out-file test.htm


Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. MotoX80 37,696 Reputation points
    2023-05-02T00:18:50.2333333+00:00

    Since we don't have access to your web site, we won't be able to test your code and fix what's wrong. I don't think that setting LoginButton to 'SIGN IN' is going to do anything, but then again, I don't know how that page works.

    Check out the final post in this thread.

    https://social.technet.microsoft.com/Forums/ie/en-US/cd4b9c9c-cd4e-4559-86d5-949eefae243f/login-to-website-using-invokewebrequest

    Be sure to review the 2 links after "Reference from:"

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.