I have a automated IE script (powershell 2.0) to webscrape a serial number. The script bypasses a login page, and scrapes a serial number off a certain page.
However i am having issues in write-output said serial number on the first run of my script. (when i run the script the second time (with the previous ieObject visible), it remembers the login and outputs the correct serial number.
$element = $currentDocument.IHTMLDocument3_getElementById("serialno")| Select innerHTML
write-output "StartScript"
Start-Sleep -s 3
$ieObject | Invoke-IEWait
write-output $element
write-output "EndScript"
i have used debug mode on the script, and $element
contains the correct information at the end of the script (i put a breakpoint on write-output "End"
) however it outputs
StartScript
EndScript
Another issue is that if i run the script again, while the original ieObject is still open, the second script remembers the password and actually scrapes correctly?
StartScript
innerHTML
---------
2390
EndScript
I do not see how my first script can be bugged, when $element has the correct data up until the end of the script, and write-output can clearly read the object since it can do it in the second execution.
Thanks for any help, this has had me stuck for a while
Big thanks to @iRon
write-output $element.innerHTML
works perfectly :)