I am trying to login into a website via powershell ISE. The Web page comes up but it doesn't enter the credentials.
$username = "DSmith"
$password = "Password123"
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$false
$ie.navigate("https://feedback.camdenccg.nhs.uk/acl_users/credentials_cookie_auth/require_login? came_from=https%3A//feedback.camdenccg.nhs.uk/james-wigg-and-queens-crescent-practices/4ef32a4e/download_responses%3Foverride-query%3DTrue")
while($ie.ReadyState -ne 4) {start-sleep -m 100}
$ie.document.getElementById('__ac_name').value= "$username"
$ie.document.getElementById('__ac_password').value = "$password"
$ie.document.getElementById("loginform").submit()
start-sleep 5
The Error I get is:
The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))
At line:10 char:7
+ while($ie.ReadyState -ne 4) {start-sleep -m 100}
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
You cannot call a method on a null-valued expression.
At line:12 char:1
+ $ie.document.getElementById('__ac_name').value= "$username"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Look for the tag name to set the value and then use the input value to do the clicking. (note: there are other ways of accomplishing this , I'm just giving you an example)
$username = "your user name"
$password = "your pass word"
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$true
checkUrlStatusOk -endpoint $rabbitMQEndpoint
$ie.navigate("https://feedback.camdenccg.nhs.uk/acl_users/credentials_cookie_auth/require_login? came_from=https%3A//feedback.camdenccg.nhs.uk/james-wigg-and-queens-crescent-practices/4ef32a4e/download_responses%3Foverride-query%3DTrue")
while($ie.ReadyState -ne 4) {start-sleep -m 100}
$userField = $ie.document.getElementsByName("__ac_name")
@($userField)[0].value =$username
$passField = $ie.document.getElementsByName("__ac_password")
@($passField)[0].value =$password
#login submit
$loginButton = $ie.document.getElementsByTagName("input")
Foreach($element in $loginButton )
{
if($element.value -eq "Log In"){
Write-Host $element.click()
}
}
Start-Sleep 10
User contributions licensed under CC BY-SA 3.0