Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

[Forum FAQ] How To Automatic Sign In Websites with Windows PowerShell

$
0
0

To sign in the websites, we need to input the username and password, then click sign in. However, in some cases, we need to do this automatically.

We can achieve this in Windows PowerShell through the method of “getElementById” with Internet Explorer object.

However, the elementbyid ($ie.Document.getElementById) is different with different webpages. Therefore, the most important thing is to get the telementids of “username”, “password” and “signin” from the javascript of the website.

In this demo, we will show you how to achieve this for outlook.com.


1. Open the website, https://login.live.com/ (Figure 1).

Figure 1: Login UI


2. Press F12 to view the source code of the website.


When you click the part “<div id=”shellTD” style=”width: 100%;”>…</div>”, you will find the login webpage changes the color, to locate the elementids, click the drop button next to the line (Figure 2).

Figure 2: View the source code


3. Continue to find the source code for the blue part of the login webpage which contains the TAG “email”, “password” and “signin” (Figure 3).

Figure 3: View the source code locating the login part


4. Click the drop button next to “div id=”signinTD” Style=”””.


1) When you find the source code like “input….”, and the color where we need to input the Microsoft account changes to blue, then find the tag “id=”i0116””, which is the elementid of “email” (Figure 4).

Figure 4: View the source code locating the “email address


2) When you find the Tag “input…”, and the color of the password field changes to blue, the “id=”i0118”” is the elementid of “password”.

Figure 5: View the source code locating the “password


3) Find the elementid “id=”idSIButton9”” of the “signin” (Figure 6).

Figure 6: View the source code locating the “signin


5. The PowerShell script to login outlook.com.

$username = "myemail@outlook.com"

$password = "password"

$ie = New-Object -com InternetExplorer.Application

$ie.visible=$true

$ie.navigate("url")

while($ie.ReadyState -ne 4) {start-sleep -m 100}

$ie.document.getElementById("i0116").value= $username

$ie.document.getElementById("i0118").value = $password

$ie.document.getElementById("idSIButton9").click()


Related threads:

Automate a login script and exit Website - Problem with login in function

Login to site with Powershell and IE: Checking a form generated with javascript


If you need further assistance, welcome to post question in our Windows PowerShell forum.


Keyword: PowerShell Script, Signin websites automatically


Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>