Created
November 13, 2015 15:13
-
-
Save riahc3/cb07cdc366f5cc502947 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 | |
$tcpipForm.Fields | |
# Dont know what else to do here. | |
$tcpipForm.Fields.gateway="2.2.2.2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment