Working behind a proxy
New job, new PC, erf… new things to configure. Ok, I’ve created my profile, now I would like to have an up2date ‘Get-Help’. Everyone knows the command:
Update-Help
Here comes the trouble:
Update-Help : Failed to update Help for the module(s) 'Microsoft.PowerShell.Management, Microsoft.PowerShell.Security, Microsoft.PowerShell.Utility, CimCmdlets, ISE, Microsoft.PowerShell.Diagnostics, Microsoft.PowerShell.Host, Microsoft.WSMan.Management, PSDesiredStateConfiguration, PSScheduledJob, PSWorkflow, PSWorkflowUtility, Microsoft.PowerShell.Core' with UI culture(s) {en-US} : Unable to connect to Help content. The server on which Help content is stored might not be available. Verify that the server is available, or wait until the server is back online, and then try the command again. At line:1 char:1 + update-help + ~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Update-Help], Exception + FullyQualifiedErrorId : UnableToConnect,Microsoft.PowerShell.Commands.UpdateHelpCommand
Needs to be connected to the Internet… Doh!
Just a check:
netsh winhttp show proxy
returns
Current WinHTTP proxy settings: Direct access (no proxy server).
That’s where we get lost in space…
So here’s the (classic) trick:
netsh winhttp import proxy source=ie
and (if you need to be authenticated on that proxy server)
$webclient=New-Object System.Net.WebClient $creds=Get-Credential $webclient.Proxy.Credentials=$creds
The PowerShell session is now able to connect to the internet with the same parameters than our dear friend Internet Explorer!