Recently I’ve been trying to get some PowerShell deployment scripts working from behind a proxy server. There’s a lot of information all over the internet about this, but most of it does not apply if you don’t directly control the commands you want to execute, for example if your connections happen within a third party DLL. Normally for C# code you would solve this using an App.config or a Web.config, but obviously PowerShell doesn’t have this.
Anyway, after a lot of dredging around, I finally found the solution. Simply execute the following two commands, and all further connections in the session will use the proxy server transparently: