Ob1*_*lan 7 scripting powershell proxy
我必须通过 PowerShell 检索代理服务器地址和端口,以便我可以使用该Invoke-Webrequest -uri http://some-site.com -Proxy命令。预期的输出应该类似于http://proxy-server.com:port。
我有一个 PowerShell 函数来检索代理服务器地址和端口,所以我们可以在脚本中使用它?
Ob1*_*lan 11
这是实现我的目标的 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
}
}
}
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助 !
小智 10
[System.Net.WebProxy]::GetDefaultProxy() | select address
[System.Net.WebProxy]是一个对象,其静态方法之一是GetDefaultProxy(). 在select从所有列显示对我们来说,我们感兴趣,这是地址。
| 归档时间: |
|
| 查看次数: |
57472 次 |
| 最近记录: |