Sending POST Data via PowerShell

by Apr 29, 2010

Often, feedback or votes on Web pages are sent back via POST requests. You can send this kind of information via PowerShell as well. You should simply create a POST request with the target URL and the desired parameters/information and send it off:

$url = "http://someurl"
$parameters = "vote=true&poll_id=2" # your POST parameters

$http_request = New-Object -ComObject Msxml2.XMLHTTP
$http_request.open('POST', $url, $false)
$http_request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded")
$http_request.setRequestHeader("Content-length", $parameters.length)
$http_request.setRequestHeader("Connection", "close")
$http_request.send($parameters)
$http_request.statusText

Twitter This Tip! ReTweet this Tip!