How do I acquire the Windows system proxy using Powershell?

I know about this

$webproxy = (get-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').ProxyServer

Is there something more generic, or is that the best?


Don't know of anything better than that I'm afraid.

It goes straight to the setting and access to the registry is pretty efficient.

| improve this answer | |
  • You're probably right. – CMCDragonkai Jun 12 '14 at 7:41

Its a shame, that Microsoft does not have a function to use the proxy for a given target "out of the box".

Currently, you manually need to check the proxy-settings in HKLM and HKCU, lookup in..\Software\Microsoft\Windows\CurrentVersion\Internet Settings, if the ProxyEnable=1 and if so, then parse the list of ProxyServers for the first one supporting the right protocol (ALL, HTTP, HTTPS...). Then you need to check, if you should bypass the proxy for your specific destination or not via ProxyOverride (also needs to check the local intranet-settings and all listed target-domains, in case the proxy skipps intranet-addresses).

Finally, dont forget to parse the AutoProxy-Settings for a PAC-file or if the WPAD-protocol is enabled via AD or DHCP. Not to mention the prompt for any required proxy-credentials. That is a terrible long code just to get the right proxy for a single target...but that way it will work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.