Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell IE webpage Automation

$
0
0
Alright so here's my problem i've been trying to automate an IE session, i've got the logging into the website down just trying to input Into a Search field, change a dropdown selection and click the Go button. I've been trying to use $ie.Document.getElementById("").value = $variable and multiple variations of getElementByTagName, getElementByName, so on....with no luck, the html code has no id tag so i feel like that is making this more complicated than it needs to be, so below i will post the html code for the input box, go button so on and some of the code i've been trying to use. Any ideas would be greatly appreciated, thanks!

HTML Code

Selection Drop Down Html Code

<select onchange="SearchProperty_OnChange(this);" class="SearchFormSelectList" name="SearchProperty"><option value="displayName">User Display name</option><option selected="" value="userPrincipalName">Logon name</option><option value="samAccountName">Logon name (pre-W2K)</option><option value="$McsFriendlyName">Name</option><option value="description">Description</option><option value="$McsFriendlyPath">User Path</option></select>

Search Field html code

<input type="text" class="FormTextInput" name="MatchString" value="" size="20">

Go Button html code

<input class="formButton" type="submit" value="Go">

My CODE

$userurl = "res://ieframe.dll/invalidcert.htm?SSLError=50331648#mywebsite.com"
$ie = New-Object -comobject InternetExplorer.Application
$ie.visible = $true
$ie.silent = $true
$ie.Navigate( $userurl )
while( $ie.busy){Start-Sleep 1}
$secLink = $ie.Document.getElementsByTagName('A') | Where-Object {$_.innerText -eq 'Continue to this website (not recommended).'}
$secLink.click()
while( $ie.busy){Start-Sleep 1}

##########################ABOVE CODE WORKS

#Logon code

$iexp = Select-Window iexplore | Set-WindowActive
$iexp | Send-Keys "DOMAIN\$USERNAME{TAB}$p{TAB}{TAB}{ENTER}"

#Another issue i have is with the logon code it attempts to enter the password twice for some reason...but this results in #opening a new IE windows and it trys to search the password...not sure what is happening there...

#Here is my main issue...i've tried multiple variations of this code with no success....none of these work

$ie.Document.getElementByTagName("MatchString").value = $usersearch
$ie.Document.getElementById("MatchString").value = $usersearch
$ie.Document.getElementById("input.formtextinput").value = $usersearch
$ie.Document.getElementById("formtextinput").value = $usersearch
$ie.Document.getElementByTagName("SearchProperty").value = "Logon name"

$Go = $ie.Document.getElementsByValue('Go')# | where {$_.innerText -eq 'Go'}
$Go.click()

Viewing all articles
Browse latest Browse all 15028

Trending Articles