代码:
New-Object System.Net.WebProxy($Env:http_proxy, $true, @('localhost', '*.domain.com')
因错误而失败:
New-Object : Exception calling ".ctor" with "3" argument(s): "parsing "*.domain.com" - Quantifier {x,y} following nothing."
At line:1 char:6
+ $p = New-Object System.Net.WebProxy($Env:http_proxy, $true, @('*.domain.com', 'l ...
Quantifier {x,y} following nothing
是正则表达式错误,这很奇怪。我尝试使用正则表达式转义字符,但没有。
任何解决方案?
答案 0 :(得分:2)
我把它搞砸了至少两次 - 然而,以下似乎只是一次正确添加它:
$wp = New-Object System.Net.WebProxy($Env:http_proxy, $true)
$wp.BypassArrayList.Add('localhost')
$wp.BypassArrayList.Add('*.domain.com')
输出
Address :
BypassProxyOnLocal : True
BypassList : {localhost, *.domain.com}
Credentials :
UseDefaultCredentials : False
BypassArrayList : {localhost, *.domain.com}
答案 1 :(得分:1)
查看at this,声明第三个参数是一个正则表达式字符串数组 - *.domain.com
不是有效的正则表达式,因为字符类必须在*
之前。
如果您将其更改为.*.domain.com
,则无效:
[PS] > New-Object System.Net.WebProxy($Env:http_proxy, $true, @("localhost.domain.com",".*.domain.com"))
Address :
BypassProxyOnLocal : True
BypassList : {localhost.domain.com, .*.domain.com}
Credentials :
UseDefaultCredentials : False
BypassArrayList : {localhost.domain.com, .*.domain.com}