November 13, 2015 at 12:37 am #31911ParticipantPoints: 0Rank: Member
Im trying to logon to a web page, go to a page, modify a value, and save it.
There are two ways to do this: "$ie = New-Object -com internetexplorer.application;" OR "Invoke-WebRequest". I perfer to do the way that is more clear to me.
Trying to do it thru "$ie = New-Object -com internetexplorer.application", I get a error when trying $ie.Document.getElementsByName as in:
Cannot find an overload for "getElementsByTagName" and the argument count: "1".
This only happens in Windows Server 2012 R2, not in Windows 7.
I havent played around too much with Invoke-WebRequest as Im not too sure how to do it.
I had this for now:
$initialRequest = Invoke-WebRequest -Uri 'http://192.168.100.97/csl/login' -SessionVariable WebSession1
form = $initialRequest.Forms
$form.fields.userpwd = "mypass"
$form.fields.username = "myuser"
$loginRequest = Invoke-WebRequest -Uri ('http://192.168.100.97/csl/login' + $form.Action) -Method Post -Body $form.fields -WebSession $WebSession1
$tcpipRequest = Invoke-WebRequest -Uri 'http://192.168.100.97/form/Device?act=5' -WebSession $WebSession1
# TODO: After this, I want to first test going to I need to go http://192.168.100.97/form/Device?act=5
# TODO: Then I need to get the text value inside a textbox called gateway
So how do I keep going?
November 13, 2015 at 11:31 am #31931KeymasterPoints: 1,644Rank: Community Hero
The IE COM object is imperfectly mapped into .NET by Interop, meaning it isn't always reliable – as you're seeing. And, most importantly, it doesn't exist on most servers as it does on clients – which is WHY you're seeing what you are.
This is going to require quite a bit of familiarity with how the HTTP protocol works.
The topic ‘Login onto webpage: getElementsByTagName and Windows Server 2012 R2’ is closed to new replies.