Created
January 7, 2010 05:29
-
-
Save nolim1t/271018 to your computer and use it in GitHub Desktop.
Sample HTTP Request in Powershell
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
Powershell HTTP Request | |
$r = [System.Net.WebRequest]::Create("http://url/") | |
$resp = $r.GetResponse() | |
$reqstream = $resp.GetResponseStream() | |
$sr = new-object System.IO.StreamReader $reqstream | |
$result = $sr.ReadToEnd() | |
write-host $result | |
Username and passwords | |
$creds = new-object System.Net.NetworkCredential "username", "password" | |
$uri = mew-object System.Uri "http://url/" | |
$credcache = new-object System.Net.CredentialCache | |
$credcache.Add($uri, "Basic", $creds) | |
$webrequestobject.Credentials = $credcache |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shouldnt we close or dispose the response.