TL;DR
Key code:
$proxyUrl = "http://your-proxy-url:port"
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy($proxyUrl)
[system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
Replace "http://your-proxy-url:port" with your own proxy url and port.
For current session:
Input key code into your current PowerShell session.
Permanently
- Use Notepad to edit PowerShell Profile:
notepad $PROFILE
-
Optional: If File Explorer alert that cannot find this file, you should create One:
New-Item -Path $PROFILE -ItemType File -Force
- Add key code into this profile. Save.
- Open a new PowerShell session to apply this change
-
Optional: If an error message indicates that the execution of scripts is disabled on your system due to the current PowerShell execution policy in the new session, do:
- Right-click on the PowerShell icon and select "Run as Administrator".
- Run the following command to set the execution policy to RemoteSigned, which allows scripts created on your local computer to run:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser