Apologies, I'm incredibly new to PowerShell (And scripting in general), and I'm having a problem with the very basics of IE Automation that I can't quite get my head round. What I want to do is have a script that automatically logs onto a webpage, and then inputs data into a form. But I can't seem to input data into the text input fields on the login page. I've been scouring the internet left right and centre, but haven't yet found the answer, though I imagine it will be an obvious one.
Here is my script so far:
$ie = new-object -ComObject InternetExplorer.Application;
$requestUri = "www.testurl.com"
$ie.visible = $true
$ie.navigate($requestUri)
while ($ie.ReadyState -ne 4)
{
start-sleep -Seconds 1;
}
$doc = $ie.Document
$doc.GetElementById("ppm_login_username") = $userName
$userName.value = "UserName"
However, whenever I run the script, I get the error
The property 'value' cannot be found on this object. Verify that the property exists and can be set.
+ $userName.value = "UserName"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
I have no experience with a lot of this, so again, apologies for using incorrect terminology. Using the DOM explorer, the input field has the following line of code:
<INPUT id=ppm_login_username maxLength=240 size=40 name=userName>
So I'm confident that I'm getting the correct object, but it doesn't seem to accept the 'value' method when trying to pass data through to it.
Value does show up as a property of the object though, so I can't understand why it doesn't pass through. Any help and time you can offer is greatly appreciated!