{"id":1166,"date":"2010-07-19T14:08:44","date_gmt":"2010-07-19T05:08:44","guid":{"rendered":"http:\/\/livedevil.net\/?p=1166"},"modified":"2010-07-19T14:08:44","modified_gmt":"2010-07-19T05:08:44","slug":"powershell-web-ftp-request-response","status":"publish","type":"post","link":"https:\/\/talsu.net\/?p=1166","title":{"rendered":"Powershell &#8211; Web (FTP) Request, Response"},"content":{"rendered":"<p>Powershell \uc744 \uc774\uc6a9\ud558\uc5ec \uc6f9 \uc694\uccad\uc744 \ud574\ubcf4\uc790. \uc6f9 \uc0ac\uc774\ud2b8\ub97c \uad00\ub9ac \ud558\uac70\ub098 Rest \ubc29\uc2dd\uc758 \uc11c\ube44\uc2a4\ub97c \uc0ac\uc6a9 \ud560 \ub54c \uc720\uc6a9\ud558\ub2e4.<\/p>\n<h2>Get-WebResponseString<\/h2>\n<pre class=\"lang:ps decode:true\">\nFunction Get-WebResponseString\n{\n\tparam (\n\t\t[Parameter(Mandatory=$true)]\n\t\t[String]$Url,\n\t\t[Parameter(Mandatory=$true)]\n\t\t[String]$Method,\n\t\t[Parameter(Mandatory=$false)]\n\t\t[System.Net.NetworkCredential]$Credential\n\t)\n\n\t$Request = [System.Net.WebRequest]::Create($Url)\n\t$Request.Method = $Method\n\n\tif ($Credential -ne $null)\n\t{\n\t\t$Request.Credentials = $credential\n\t}\n\n\t$Response = $Request.GetResponse()\n\n\t$StreamReader = New-Object System.IO.StreamReader $Response.GetResponseStream()\n\t$StreamReader.ReadToEnd()\n}\n<\/pre>\n<h2>\uc0ac\uc6a9 \uc608<\/h2>\n<pre class=\"lang:ps decode:true\">\n$Url = \"http:\/\/Use-Powershell.com\"\n$Username = \"talsu\"\n$Password = \"pass1234\"\n\n$credential = New-Object System.Net.NetworkCredential @($Username, $Password)\n\nGet-WebResponseString -Url $Url -Credential $credential -Method \"GET\"\n<\/pre>\n<p>$Response \uc5d0\uc11c \uacb0\uacfc String\uc744 \ubc18\ud658 \ud558\uc9c0 \uc54a\uace0 .StatusCode \ub4f1 \ub2e4\ub978 \uc815\ubcf4\ub97c \ud65c\uc6a9 \ud560 \uc218 \uc788\ub2e4.<\/p>\n<p>Web \ubfd0\ub9cc \uc544\ub2c8\ub77c FTP \uc5d0\uc11c\ub3c4 \ub3d9\uc77c\ud558\uac8c \uc0ac\uc6a9 \ud560 \uc218 \uc788\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Powershell \uc744 \uc774\uc6a9\ud558\uc5ec \uc6f9 \uc694\uccad\uc744 \ud574\ubcf4\uc790. \uc6f9 \uc0ac\uc774\ud2b8\ub97c \uad00\ub9ac \ud558\uac70\ub098 Rest \ubc29\uc2dd\uc758 \uc11c\ube44\uc2a4\ub97c \uc0ac\uc6a9 \ud560 \ub54c \uc720\uc6a9\ud558\ub2e4. Get-WebResponseString Function Get-WebResponseString { param ( [Parameter(Mandatory=$true)] [String]$Url, [Parameter(Mandatory=$true)] [String]$Method, [Parameter(Mandatory=$false)] [System.Net.NetworkCredential]$Credential ) $Request = [System.Net.WebRequest]::Create($Url) $Request.Method = $Method if ($Credential -ne $null) { $Request.Credentials = $credential } $Response = $Request.GetResponse() $StreamReader = New-Object System.IO.StreamReader $Response.GetResponseStream() $StreamReader.ReadToEnd() } [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[26],"tags":[85,121,128,178,481,238,283,284],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pXV5a-iO","_links":{"self":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/1166"}],"collection":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1166"}],"version-history":[{"count":0,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/1166\/revisions"}],"wp:attachment":[{"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}