Less is more – I mean lesser the work, happier I Am 😛
Today, I’ve Automated the login process of few of my most used websites, like Facebook, Gmail, LinkedIn and Microsoft Live.
HOW IT WORKS :
Here I’ve created Internet explorer objects and have passed them URL’s so that gets open in the IE browser.
Now the script have to wait until the web page gets loaded into the browser, so that we have in hand HTML data to play.
Once you have your page loaded, use HTML DOM (Document Object Model) to parse HTML source code and identify the input fields, where you can feed in you login credentials.
Read the full article on my new website RidiCurious.com
Book Announcement : PowerShell Scripting Guide to Python
https://leanpub.com/PowerShell-to-Python/embed
This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.
“Use what you know to learn what you don’t. ” also known as Associative learning.
Book follows a comparative method to jump start readers journey in Python, but who is the target audience? and who should read this book –
- Any System Administrator who want to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
- Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.
Python is one of the top programming languages and in fast changing IT scenarios to DevOps and Cloudto the future – Data Science, Artificial Intelligence (AI) and Machine Learning Python is a must know.
But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell
NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!
While the book is in progress, please review it and send any feedback or error corrections at prateek@ridicurious.com
Hi, could you also make it for spotify? https://play.spotify.com/?utm_source=web-player&utm_campaign=bookmark
LikeLike
I did it.
# Feed in your credentials to input fields on the web page
$usernamefield = $ie.Document.getElementByID(‘login-usr’)
$usernamefield.value = ‘xxxxxxx’
$passwordfield = $ie.Document.getElementByID(‘login-pass’)
$passwordfield.value = ‘xxxxxxx’
#$Link=$ie.Document.getElementByID(‘signup-spotify’)
$Link=$ie.Document.getElementsByTagName(“button”)
Foreach ($btn2 In $Link)
{
if ($btn2.outerHTML -eq “Login”)
{
$btn2.Click()
}
else{
}
}
LikeLiked by 1 person
Cool 🙂
LikeLike
Hi, could you also make it for http://www.vivint.com/?
LikeLike
Hi, What todo about below errors ?
You cannot call a method on a null-valued expression.
At C:\Users\43919773\Desktop\AUTO\25102016\one-connect.ps1:14 char:1
+ $usernamefield = $ie.Document.getElementByID(‘userid’)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
LikeLike
Hi Prateek,
Is it possible that I can automate different set of email ID and password combination and run the script so that all can login in the website one by one.
Thanks,
Amit Prakash
LikeLike
Hi Prateek,
can assist me in below —
the requirement is as below
1- Open multiple tab for all different Sites
2- Remove security SSL
3- Auto key user ID and Password
4- Hit enter to get login
5- from step 2-4 go one by one sites
6- Close complete IE in every 5 min and reopen and steps 1-6
Please assist and u may mail me at mukeshgupta23may@gmail.com
LikeLike
Dear Pratik,
I want to know that upto login it’s fine. After login, there is one button to be click and then have to click logoff. How can we script for these two?
LikeLike
You’ve to identify the html elements ID for the button and the Log off button\link and then just like we clicked on button to login you’ve to perform the same for these buttons
LikeLike
Hi there,
Thanks for the post, it could potentially be very useful for me.
I am struggling to find the Login button id at the below web page. Any chance you would know what it is? I can only see a class name. Can this be used? if so how is it referenced?
https://viewer.leverton.de/login/auth
Many thanks in advance.
LikeLike
Does it works for Chrome or other browser?
LikeLike
You can use Selenium to automate Chrome browser.
LikeLike
Hi
I have a button my page which looks like this:
How can I get this clicked?
This is what I have tried but doesnt work:
$Link2=$ie.Document.getElementsByTagName(“BUTTON”) | where-object {$_.class -eq “Download”}
$Link2.click();;
Thank you.
LikeLike
Sorry I missed something in the above post.
The button looks like this:
LikeLike
Looks like the html codes are automatically erased. I have spaced out the syntax a little in case it gets blocked.
LikeLike
Hey all,
Just wanted to say, I recommend doing it using “Document.LocationURL -like “*facebook*” instead of LocationName.
Reason being that the URL is (likely) never going to change, but small changes in the title/name provided by the code can occur on various sites.
Thanks for the script above, it made completing a script I’ve been working on very easy, I didn’t realize I could pipe existing IE tabs into a new ComObject.
Cheers!
LikeLiked by 1 person
Thanks for the tip! I’ll look into it
LikeLike
Hi Singh, my website source code doesn’t have “id” so I can’t seem to getElementbyId to work.
The website I am trying to access has a “data-bind” call :
How can I get your powershell script to work with these fields
Thanks
LikeLike
Can you share a sample of the HTML in pastebin?
LikeLike
here is the HTML sample:
Help
Support
Forgot Password?
Username:
Password:
Login
LikeLiked by 1 person
Hi Prateek – I would like my script to click on the Citrix Publish Application “My Production App”. However it not click on it.
Here is the HTML Code:
… ==$0
My Production App
Here the code i’m trying to use:
$Link = $ie.Document.getElementsByTagName(‘a’) |
Where-Object { $_.ClassName -eq “My Production App” }
Select-Object -First 1
Any suggestions would be appreciated.
Thanks
LikeLike
Hi Prateek – I would like my script to click on the Citrix Publish Application “My Production App”. However it will not click on “My Production App”
Here is the HTML Code below
… ==$0
My Production App
Here the code i’m trying to use:
$Link = $ie.Document.getElementsByTagName(‘a’) |
Where-Object { $_.ClassName -eq “My Production App” }
Select-Object -First 1
Any suggestions would be appreciated.
Thanks
LikeLike
I have a sight that once I log in and navigate around I must then click a link. This creates a new tab in internet explorer and appears to open as active. However when I use this bit of code $IE = (New-Object -COM “Shell.Application”).Windows() | ?{$_.locationname -like ‘*(tab name)*’}
If($IE.Document -eq $null){ $IE.Refresh()}
I get a null-valued expression error on the refresh line. I can not force the link to open in the current tab. Once I can resolve this issue I will have to navigate to another link and repeat the new tab process again before I can finally get to the page I need. Any help is appreciated. Thank you.
LikeLike
[…] » Visit Now Jun 07, 2015 · Powershell : Automated Login to All your Websites in One Go. Less is more – I mean lesser the work, happier I Am […]
LikeLike
[…] » Visit Now Jun 07, 2015 · Powershell : Automated Login to All your Websites in One Go. Less is more – I mean lesser the work, happier I Am […]
LikeLike
[…] » Visit Now Jun 07, 2015 · Powershell : Automated Login to All your Websites in One Go. … Is it possible that I can automate different set of email ID and password combination and run the script so that all can login in the website one by one. Thanks, Amit Prakash. Like Like. mukesh. February 25, 2017 at 7:37 pm Reply. […]
LikeLike
[…] » Visit Now Jun 07, 2015 · Powershell : Automated Login to All your Websites in One Go. … Is it possible that I can automate different set of email ID and password combination and run the script so that all can login in the website one by one. Thanks, Amit Prakash. Like … Looks like the html codes are automatically erased. I have spaced out the syntax a little in … […]
LikeLike
[…] » Visit Now Jun 07, 2015 · Powershell : Automated Login to All your Websites in One Go. Less is more – I mean lesser the work, happier I Am […]
LikeLike