Skip to content

Instantly share code, notes, and snippets.

@geunho
Created January 14, 2019 06:35
Show Gist options
  • Save geunho/972821167a410b28ef07c42c12914161 to your computer and use it in GitHub Desktop.
Save geunho/972821167a410b28ef07c42c12914161 to your computer and use it in GitHub Desktop.
powershell 2 web get request
################################################################################################
# http get request
################################################################################################
$uri = "http://mydomain/~"
$webclient = [System.Net.HttpWebRequest]::Create($uri)
[System.Net.HttpWebResponse]$res = $webclient.GetResponse()
$reader = New-Object System.IO.StreamReader($res.GetResponseStream())
$result = $reader.ReadToEnd()
################################################################################################
# deserialize json to powershell object
################################################################################################
[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
$ser = New-Object System.Web.Script.Serialization.JavaScriptSerializer
$resObj = New-Object PSObject -Property $ser.DeserializeObject($result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment