Determine the proxy server when automatic detection is used

By , March 25, 2010 9:09 AM

If a browser is configured to detect proxy server settings automatically, the proxy server address is never displayed anywhere in the browser. You may have an application, however, that requires you to explicitly define the proxy server to use. To determine the server to use, you can use PowerShell. (You can’t do it as a one-liner because the System.Net.WebClient class doesn’t have any static methods, which means you have to load the class before you can call any of the methods.)

$webclient = new-object System.Net.WebClient
$webclient.Proxy.GetProxy("http://www.cnn.com").Authority

The URL to use in the query can be anything as long as it is one that will evaluate to using a proxy server, so don’t use an internal address that will evaluate to connecting directly. The query will return the DNS name of the proxy server and the port to use, e.g., proxy.company.com:8080. If you want these values separately, you can use the Host and Port properties.

One Response to “Determine the proxy server when automatic detection is used”

  1. chrissie1 says:

    I thank you so much. I could kiss you.

Leave a Reply

Panorama Theme by Themocracy