[string] $fileName = "en_sql_server_2008_r2_developer_x86_x64_ia64_dvd_522665.iso" [string] $url = "http://installers.abc/iso/$filename" [string] $tempPath = "c:\balpreet" function Download-Iso { Param( [string] $FileName,[string] $Url,[string] $destinationFolder ) [string] $destination = Join-Path -Path $tempPath -ChildPath $fileName write-host "downloading from : $url to $destination" $client = new-object System.Net.WebClient $client.DownloadFile( $Url,$destination ) } Download-Iso -FileName $fileName -Url $url -DestinationFolder = $tempPath
我试图从http可访问的远程位置下载4.07 GB(4,380,329,984字节)ISO.
Windows 7:下载完整的4.07 GB文件.
Windows Server 2008 R2:
它只下载81.4 MB(85,363,075字节)并假装完成下载.代码不会抛出任何错误,但也不会下载完整的文件.
有什么线索的原因?
解决方法
这是内部网络代理,由于某种原因,在转移81.4 MB(85,075字节)后丢弃请求.但奇怪的是webclient没有抛出任何异常,并假装下载成功.
修复是使代理为空,因此处理请求而不通过代理.
$client.proxy=$null # get rid of proxy $client.DownloadFile( $Url,$destination )