I'm trying to login to IE using the below powershell script:
$ie = New-Object -ComObject 'internetExplorer.Application'
$ie.Visible= $true # Make it visible
$password="password"
$ie.Navigate("URL")
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
$passwordfield = $ie.document.getElementByID('password')
$passwordfield.value = "$password"
$Link = $ie.document.getElementByID('Login')
$Link.click()
And below is the HTML code of my URL:
<form action="index.cfm?event=dashboard:config.index" method="post">
<h4>Password</h4>
<p>
<input type="password" name="password" value="" size="20">
<input type="submit" value="Login">
</p>
I get the below error message:
You cannot call a method on a null-valued expression. At line:14 char:1 + $Link.click() + ~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull