I can login to facebook, or google, or stackoverflow using this simple script (or a slight variation depending on the Ids). However, my company has a website and I can't login to that using powershell.
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$true
$ie.navigate("www.loginpage.com")
start-sleep 1;
# I was using this before, but it would never leave the loop...
# while($ie.ReadyState -ne 4) {start-sleep -m 100}
$ie.document.getElementById("username").value = "username"
$ie.document.getElementById("password").value = "password"
$ie.document.getElementById("loginform").submit()
The only difference I think is that the website is on our "Intranet", not the internet, and for some reason powershell distinguishes between the two. But I'm not sure, I can still normally open up IE and go to the url and view source and see the tag ID's and whatnot.
Does anyone know why I'm getting the following error when I use $ie.document.getElementById in this case.
You cannot call a method on a null-valued expression.
+ CategoryInfo : InvalidOperation: (getElementById:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
I know the tags are:
<input name="username" id="username" langcode="EN" type="text">
<input name="password" id="password" type="password">
Any ideas?