locked
Invoke-WebRequest loginform RRS feed

  • Question

  • Hi everybody.

    I know it's a bit out of scope, but i thought that maybe someone had an idea anyway :)

    I have an Ruckus 7341 AP. I would like through powershell to login and pull some information about connected clients. Then I thought i could use Invoke-Webrequest for that the same way i have done with many other things. But when i try it keeps getting me the login page. Here's what i tried:

    $result = Invoke-WebRequest -Uri "http://192.168.1.2"
    $result.Forms[0].Fields.'login-username' = "super"
    $result.Forms[0].Fields.password = "*******"
    Invoke-WebRequest "http://192.168.1.2/forms/doLogin" -SessionVariable th -Body $result.Forms[0] -Method Post
    $data = Invoke-WebRequest -Uri "https://192.168.1.2/index.asp" -WebSession $th

    Any thoghts?


    Thursday, January 30, 2014 11:19 AM

Answers

  • I figured out what was missing using Fiddler. Then i ended up making a custom parameter set as body:

    $postParams = @{login_username="username";password="password";x=113;y=15}

    • Marked as answer by Yan Li_ Thursday, February 13, 2014 9:18 AM
    Monday, February 10, 2014 2:22 PM

All replies

  • Hi,

    Please try below code to signin a wen page, we should modify the name the elements according to the wenpage you use:

    $url = "http://192.168.1.2" 
    $username="Your_username" 
    $password="Your_password" 
    $ie = New-Object -com internetexplorer.application; 
    $ie.visible = $true
    $ie.navigate($url); 
    while ($ie.Busy -eq $true

        Start-Sleep -Milliseconds 1000; 

    $ie.Document.getElementById("User").value = $username 
    $ie.Document.getElementByID("Passwd").value=$password 
    $ie.Document.getElementById("signin").Click();

    Regards,

    Yan Li


    Regards, Yan Li

    Friday, January 31, 2014 10:14 AM
  • Hi,

    Please try below code to signin a wen page, we should modify the name the elements according to the wenpage you use:

    $url = "http://192.168.1.2" 
    $username="Your_username" 
    $password="Your_password" 
    $ie = New-Object -com internetexplorer.application; 
    $ie.visible = $true
    $ie.navigate($url); 
    while ($ie.Busy -eq $true

        Start-Sleep -Milliseconds 1000; 

    $ie.Document.getElementById("User").value = $username 
    $ie.Document.getElementByID("Passwd").value=$password 
    $ie.Document.getElementById("signin").Click();

    Regards,

    Yan Li


    Regards, Yan Li

    Thanks for the reply Yan.

    I get an error:

    Property 'Value' cannot be found on this object; make sure it exists and is settable.
    At line:1 char:1
    + $ie.Document.getElementById("user").Value = 'super'
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound

    Monday, February 3, 2014 9:23 AM
  • Hi,

    This code should be modified according to the web page that you want to access, we should make sure that in the web page, there are "user", "password" textbox, that we should enter text.

    Please run below code:

    $ie.Document.getElementById("User")

    $ie.Document.getElementById("User") |gm

    $ie.Document.getElementByID("Passwd")

    $ie.Document.getElementByID("Passwd")|gm

    Make sure that the get-member command list out value properties fot the object.

    Regards,

    Yan Li


    Regards, Yan Li


    • Edited by Yan Li_ Friday, February 7, 2014 5:21 AM edit
    Friday, February 7, 2014 5:19 AM
  • I figured out what was missing using Fiddler. Then i ended up making a custom parameter set as body:

    $postParams = @{login_username="username";password="password";x=113;y=15}

    • Marked as answer by Yan Li_ Thursday, February 13, 2014 9:18 AM
    Monday, February 10, 2014 2:22 PM