Script not allowing to auto-login to a website

Welcome Forums General PowerShell Q&A Script not allowing to auto-login to a website

This topic contains 7 replies, has 5 voices, and was last updated by

 
Participant
8 months, 1 week ago.

  • Author
    Posts
  • #95645

    Participant
    Points: 1
    Rank: Member

    Hello folks,
    I am trying to write a script that allows an auto-login to a website, for example LinkedIn.com, when you run the script, you can see the Username/Password being entered, but then stops; i.e. does not login to the site. Please see the code below, is anyone able to advise where I am going wrong?, many thanks.

    $username = "enter username here"
    $password = "enter password here"
    $ie = New-Object -com InternetExplorer.Application
    $ie.visible = $True
    $ie.navigate("https://www.linkedin.com")
    while($ie.ReadyState -ne 4) {start-sleep -seconds 3}
    $ie.document.getElementById("login-email").value= "$username"
    $ie.document.getElementById("login-password").value = "$password"
    $final_login = $ie.document.getElementById('login-submit')
    $final_login.click()
    start-sleep 3

  • #95648

    Keymaster
    Points: 1,638
    Helping HandTeam Member
    Rank: Community Hero

    A lot of websites have implemented code to stop this from working, because they deal with so many malicious bots. In those cases, there's not much you can do.

    • #95685

      Participant
      Points: 1
      Rank: Member

      Hi Don,
      That makes very good sense; I was very focussed to making it work but did not come to the realization that the website could see the auto-login as potentially malicious, thank you for that.

  • #95663

    Participant
    Points: 2
    Rank: Member

    If I'm using the code to test the site's availability, can I set the website to allow connections from a defined source? I've been trying to learn enough Linux to deploy a Xymon monitoring server, but I keep thinking that there has to be a way to do it with PS instead.

    Thanks,
    Patrick

  • #95714

    Participant
    Points: 226
    Helping Hand
    Rank: Participant

    They indeed block this auto-logon on the landing page.

    That 'Sign in'/'Login', button is really not a button at all. You can see that by walking the form object element and other page elements. No matter how you try to hit it, by id, name, tag, class, etc. It will fail.

    If you look at the page / element source. It's one of that has a disabled element.

    input tabindex="1" disabled="" class="login submit-button" id="login-submit" type="submit" value="Sign in"

    • #95720

      Participant
      Points: 2
      Rank: Member

      Thanks, postanote. Now I know what I'm looking at, but you and Don have a point, it's too general to risk. I'll find a way to test that the conditions for logging in are present instead.

      Thanks!
      Patrick

  • #95781

    Participant
    Points: 1
    Rank: Member

    Hello Joe,

    The element is indeed disabled, but it is possible to just enable this.

    Just add the below line before the $final_login.click()

    $final_login.disabled = $False

    Thanks,
    Francis.

    • #95786

      Participant
      Points: 1
      Rank: Member

      Hi Francis,
      Excellent, that worked very nicely!, thank you very much for that.

The topic ‘Script not allowing to auto-login to a website’ is closed to new replies.