-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSet-Proxy.ps1
36 lines (27 loc) · 1.15 KB
/
Set-Proxy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Param(
[string]$pwd
)
$domain = $env:USERDOMAIN
$user = $env:USERNAME
$uriPwd = [uri]::EscapeUriString($pwd)
$proxy = ([System.Net.WebProxy]::GetDefaultProxy() | Select-Object -First 1 Address).Address.ToString()
$proxArr = [System.Text.RegularExpressions.Regex]::Split($proxy, '://')
$uriEncodeProxy = [string]::Format('{0}://{1}:{2}@{3}', $proxArr[0], $user, $uriPwd, $proxArr[1])
Write-Host 'Domain: ' $domain
Write-Host 'User: ' $user
Write-Host 'Proxy: ' $proxy
#Write-Host 'Authenticated Proxy: ' $uriEncodeProxy
# git
git config --global http.proxy $uriEncodeProxy
# npm/nodejs
npm config set proxy $uriEncodeProxy
npm config set https-proxy $uriEncodeProxy
# nuget
# nuget config -set http_proxy=$proxy
# nuget config -set http_proxy.user=($domain + '\' + $user)
# nuget config -set http_proxy.password=$pwd
#sublime
#docker
# [Environment]::SetEnvironmentVariable("HTTP_PROXY", $uriEncodeProxy, [EnvironmentVariableTarget]::Machine)
# [Environment]::SetEnvironmentVariable("HTTPS_PROXY", $uriEncodeProxy, [EnvironmentVariableTarget]::Machine)
# Restart-Service docker