Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function InvokeWebRequest ([string]$url)
- {
- try
- {
- $webrequest = [System.Net.WebRequest]::Create($url)
- $response = $webrequest.GetResponse()
- $stream = $response.GetResponseStream()
- $sr = new-object System.IO.StreamReader($stream)
- $content = $sr.ReadToEnd();
- return $content
- }
- catch { Write-Error $_.Exception.Message }
- finally
- {
- if($sr -ne $null) { $sr.Close(); }
- if($response -ne $null) { $response.Close(); }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement