jeudi 28 juin 2018

Unable to login to a website using powershell

I am trying to login to a site using the below code,

$IE = New-Object -ComObject InternetExplorer.Application

$Url = "https://example.com"

$IE.Navigate($Url)

$IE.Visible = $true

 while ($IE.busy) {
 start-sleep -milliseconds 1000 
 } 



$elements = $IE.Document.getElementById("userID")

Foreach($element in $elements)
    {
        $element.value = "user"
    } 


$elements = $IE.Document.getElementById("pswd")

Foreach($element in $elements)
    {
        $element.value = "password"
    } 


$elements = $IE.Document.getElementByName("configCombo")

Foreach($element in $elements)
    {
        $element.value = "config"
    } 

But except navigating to the url, nothing else seems to happen.The values in the username,password and config fields are not being filled up by the code.Looked for such cases in stack overflow but couldn't find any. So posted this as a new question.

I have unchecked the the enable protected mode in IE.

Any ideas/solutions will be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire