Author Posts

March 11, 2018 at 9:48 am

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

March 11, 2018 at 2:56 pm

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.

March 12, 2018 at 1:19 am

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

March 12, 2018 at 9:52 am

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.

March 12, 2018 at 4:40 pm

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"

March 12, 2018 at 5:42 pm

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

March 13, 2018 at 1:02 am

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.

March 13, 2018 at 7:12 am

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