Testing URLs for Proxy Bypass

by Aug 14, 2012

If you'd like to find out whether a given URL goes through a proxy or is accessed directly, you can use this neat little trick:

Function Test-ProxyBypass
{
  param
  (
    [Parameter(Mandatory=$true)]
    [string]$url
  )

  $webclient = New-Object System.Net.WebClient
  return $webclient.Proxy.IsBypassed($url)
}

To test a URL, simply submit it to the function Test-ProxyBypass. The result is either $true or $false.

Twitter This Tip! ReTweet this Tip!