-
-
Save DWSR/0a5094a1418e56239f27 to your computer and use it in GitHub Desktop.
Invoke-Webrequest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# establish initial connection to website | |
$initialRequest = Invoke-WebRequest -Uri 'http://192.168.100.97/csl/login' -SessionVariable WebSession1 | |
#$initialrequest is now an object containing the html of the web request. get the form elements from the page | |
$form = $initialRequest.Forms[0] #outputting $form.fields to the screen will show you all the elements. Assuming 'username' and 'password'... | |
# update $form with username and password info and submit this back to the login webpage as POST | |
$form.fields.userpwd = "PASS" | |
$form.fields.username = "USER" | |
$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' -Method Get -WebSession $WebSession1 | |
$tcpsettingsform = $tcpipRequest.Forms[0] | |
$tcpsettingsform.gateway = '8.8.8.8' | |
$newrequest = Invoke-WebRequest -Uri "http://192.168.100.97$($form.action)" -Method $form.Method -Body $form.fields -WebSession $WebSession1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment