I need to log on to a web page with credentials from the get-credential window. But I am getting error- Property 'Value' cannot be found on this object; make sure it exists and is settable.I have provided my powershell source code here..
$url = "ameriprisestage.service-now.com/"
$cred = Get-Credential
$username = $cred.username
$username = $username.Replace("\", "")
$password = $cred.GetNetworkCredential().password
$ie = New-Object -com internetexplorer.application;
$ie.visible = $true;
$ie.navigate($url);
while ($ie.ReadyState -ne 4 -or $ie.Busy)
{
start-sleep -milliseconds 100
}
#$uname=$ie.Document.getElementsByTagName("input")
#$unameBox=$uname | where { $_.name -eq "user_name" }
$unameBox=$ie.Document.getElementById("user_name")
$unameBox.value = $username
$pass=$ie.Document.getElementsByTagName("input") | ? { $_.id -eq "user_password" }
$pass.value = $password
$pass.select
$buttn=$ie.Document.getElementsByTagName("button") | ? { $_.id -eq "sysverb_login" }
$buttn.click()
while($ie.busy) {
Start-sleep 1;
}
getElementsByTagName. Just because IE reports that it is no longer busy does not mean any/all page load scripts have completed. Might be worth coding a loop to wait until this step is successful.start-sleep -seconds 60before querying the DOM. This should give the page time to render. If it still fails then either you are looking for elements that don't exist, or using the wrong syntax.