Skip to content

Instantly share code, notes, and snippets.

@riahc3
Created November 13, 2015 15:13
Show Gist options
  • Save riahc3/cb07cdc366f5cc502947 to your computer and use it in GitHub Desktop.
Save riahc3/cb07cdc366f5cc502947 to your computer and use it in GitHub Desktop.
Invoke-Webrequest
# 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