Get-Url has been useless to me at work since it doesn't use my default proxy set up in IE.

Topics: Developer Forum
Jul 4, 2007 at 4:51 AM
I've added a couple of statements to the end of the script to load the default proxy. I'm not sure if anybody else has experienced this.

Thanks again for a wonderful tool,
Scott Hoggarth

  1. ---------------------------------------------------------------------------
      1. <Script>
      2. <Author>Keith Hill</Author>
      3. <Description>
      4. This script scrapes the web page of the supplied web URL and
      5. outputs a string containing the contents of the web page.
      6. </Description>
      7. <Usage>Get-Url http://www.codeplex.com/PowerShellCX/Project/ProjectRss.aspx</Usage>
      8. </Script>
  2. ---------------------------------------------------------------------------
param(string$Url)

function Usage {
""
"Usage: Get-Url -Url <string>"
""
"Parameters:"
" -Url : Url of web page to download"
" -? : Display this usage information"
""
exit
}

if ($args -eq '-?') {
Usage
}

if (!$Url) {
Write-Error "Please specify a url to download."
Usage
}

$webClient = new-object System.Net.WebClient
$webProxy = System.Net.WebProxy::GetDefaultProxy()
$webProxy.UseDefaultCredentials = "True"
$webClient.Proxy = $webProxy
$webClient.DownloadString($Url)
Coordinator
Jul 5, 2007 at 4:53 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.