Link to home
Create AccountLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

Using a Powershelll Script to open a website using a specific browser and then entering username and password

I would like to use a Powershell script so that when you double click on it, it will open a browser using either Internet Explorer or Chrome and then once the internal website is open to automatically enter the username and password.
It will be used internally only.
Is this possible?
Avatar of Qlemo
Qlemo
Flag of Germany image

Does the web page need to be visible, just simplyfying login?
Avatar of E=mc2

ASKER

It's just simplifying login. 
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of E=mc2

ASKER

Thanks Qlemo.
This does seem to work however if I run this manually, I get this error:

Method invocation failed because [System.DBNull] does not contain a method named 'Click'.
At C:\Users\....File.ps1:50 char:1
+ ($ie.Document.getElementById('overridelink') | select -First 1).Click ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound
Great you spotted it is PowerShell code ;-).
As said, the code depends on the site layout, and whether compatibility view is used. This particular line is used for the prompt if HTTPS is used with an untrusted CA (e.g. self-signed cert). Remove the line, it is probably unnecessary for you.
Avatar of E=mc2

ASKER

Thanks Qlemo this worked great.
Now on the next question I will open I will ask more questions about this code and how I can modify it.
Many thanks