0

我正在使用Invoke-ExpressionPowerShell 中的 cmdlet 来加载模块。

以下代码按预期工作。

$url="http://pastebin.com/raw/FuxtpN69"

IEX (New-Object System.Net.Webclient).DownloadString($url)

但是当我尝试使用变量来分割域和页面时。

$u="http://pastebin.com"
$rl="/raw/FuxtpN69"

$url="$u$rl"

IEX (New-Object System.Net.Webclient).DownloadString($url)

我收到以下路径错误:

Exception calling "DownloadString" with "1" argument(s): "The given path's format is not supported."
At line:8 char:53
+ IEX (New-Object System.Net.Webclient).DownloadString <<<< ($url)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

有人能帮我吗?提前致谢。

4

1 回答 1

0

我认为您正在以不同的帐户(例如管理员)运行 PowerShell。

也许该帐户的代理设置与您的普通帐户不同?

先看凭证部分,

$webClient.UseDefaultCredentials = $true

然后,尝试设置

$client.Proxy = $null

在下载之前看看它是否有帮助。

于 2017-01-25T15:58:10.067 回答