This is an old revision of the document!
If you access the Internet in the organization via the proxy server, by default you won’t be able to access an external webpage (Invoke-WebRequest cmdlet), update help using Update-Help cmdlet or download an application package from an external package repository (using PackageManagement or NanoServerPackage) from your PowerShell session. In this article we’ll show how to get the Internet access via proxy server with the authentication from a PowerShell session.
Let’s try to update PowerShell Help:
Update-Help
Or access an external web page:
Invoke-WebRequest http://woshub.com
If you haven’t got a direct Internet connection, the command will return a similar error:
The matter is that PowerShell (to be more precise, .NET class System.Net.WebClient that is using these cmdlets to address the external resources over HTTP) does not use system proxy settings specified in IE. However, WebClient class has some properties that allow to specify both proxy settings (WebClient.Proxy) and proxy authentication data (WebClient.Credentials or WebClient.UseDefaultCredentials). Let’s consider how to use these properties of WebClient class.
Let’s check the current settings of the system proxy in the PowerShell session:
netsh winhttp show proxy
As you can see, proxy settings are not specified
Current WinHTTP proxy settings: Direct access (no proxy server).
Import the proxy settings from Internet Explorer parameters:
netsh winhttp import proxy source=ie
or set them manually:
netsh winhttp set proxy "192.168.0.14:3128"