我必须通过Power Shell检索代理服务器地址和端口,因此我可以使用Invoke-Webrequest -uri http://some-site.com -Proxy命令.预期的输出应该看起来像 http://proxy-server.com:port. 我有一个PowerShell函数来检索
我有一个PowerShell函数来检索代理服务器地址和端口,所以我们可以在脚本中使用它?
以下是实现我的目标的PowerShell函数:function Get-InternetProxy
{
<#
.SYNOPSIS
Determine the internet proxy address
.DESCRIPTION
This function allows you to determine the the internet proxy address used by your computer
.EXAMPLE
Get-InternetProxy
.Notes
Author : Antoine DELRUE
WebSite: http://obilan.be
#>
$proxies = (Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').proxyServer
if ($proxies)
{
if ($proxies -ilike "*=*")
{
$proxies -replace "=","://" -split(';') | Select-Object -First 1
}
else
{
"http://" + $proxies
}
}
}
希望这可以帮助 !
