Friday, June 14, 2019

Enable Proxy server settings in PowerShell

proxy servers don't like you to go straight to the internet.

you get an error something like:

Invoke-WebRequest :
This Page Cannot Be Displayed
Authentication is required to access the Internet using this system. A valid user ID and password must be entered when prompted.

so you need to give this Powershell Incantation

#Proxy
$wc = New-Object Net.WebClient
    $wc.UseDefaultCredentials = $true
    $wc.Proxy.Credentials = $wc.Credentials

You can guess from this that you can actually set proxy credentials with this. But I haven't worked that out yet.

No comments:

Post a Comment