Script not allowing to auto-login to a website

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

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.

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

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.

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.

<strong>input tabindex="1" disabled=""</strong><em> class="login submit-button" id="login-submit" type="submit" value="Sign in"

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

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.

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