DEV Community

01kg
01kg

Posted on

PowerShell Proxy | How to set proxy for current session or permanently

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
Enter fullscreen mode Exit fullscreen mode

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

  1. Use Notepad to edit PowerShell Profile: notepad $PROFILE
  2. Optional: If File Explorer alert that cannot find this file, you should create One: New-Item -Path $PROFILE -ItemType File -Force
  3. Add key code into this profile. Save.
  4. Open a new PowerShell session to apply this change
  5. 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:
    1. Right-click on the PowerShell icon and select "Run as Administrator".
    2. 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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay