gpt4 book ai didi

powershell - 通过代理使用 PsGet

转载 作者:行者123 更新时间:2023-12-03 12:24:15 25 4
gpt4 key购买 nike

我很难修改 PsGet通过代理工作。我在 PsGet.psm1 上替换了每个 $client 初始化有了这个

# $client = (new-object Net.WebClient)
$proxyAddr = (get-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').ProxyServer
$proxy = new-object System.Net.WebProxy
$proxy.Address = $proxyAddr
$proxy.useDefaultCredentials = $true
$client = new-object system.net.WebClient
$client.proxy = $proxy

但在 WebClient 请求期间,我仍然不断收到 DotNetMethodException。

最佳答案

试试这个。使用 [System.Net.WebRequest]::DefaultWebProxy而不是注册表读取。

$wc = New-Object System.Net.WebClient
$wc.Headers.Add("User-Agent","Mozilla/4.0+")
$wc.Proxy = [System.Net.WebRequest]::DefaultWebProxy
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$wc.DownloadString("https://github.com/chaliy/psget/raw/master/PsGet/PsGet.psm1")

关于powershell - 通过代理使用 PsGet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8905013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com