0

我上线了: PSVersion : 5.1.17134.1

并发出此代码:

$uri = "https://someuri"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Range','bytes=0-1023')
$headers.Add('User-Agent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36')
$result = Invoke-WebRequest -Uri $uri -Headers $headers -outfile "19" 

得到这个错误:

Invoke-WebRequest : The 'Range' header must be modified using the appropriate property or method.
Parameter name: name
At line:7 char:11
+ $result = Invoke-WebRequest -Uri $uri -Headers $headers -outfile "19 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Invoke-WebRequest], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

在这种情况下,Brian 的方法似乎不起作用。为什么?

4

0 回答 0