2013-12-18 33 views
4
[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。System.Net.Webclient只下載81.4 MB(85,363,075字節)

Windows 7:它下載完整的4.07 GB文件。

Windows Server 2008 R2: 它只下載81.4 MB(85,363,075字節)並假裝完成下載。代碼不會拋出任何錯誤,但也不會下載完整的文件。

任何線索爲什麼?

+0

您是否有可能在Windows Server 2008 R2系統上的C驅動器上用完磁盤空間? – alroc

+1

這是否也與其他文件發生?我也遇到了一些企業防火牆的問題。在我的工作中,「智能」防火牆有時會認爲某些文件是病毒,並且會導致連接中斷......並且它似乎總是在同一點上殺死它。我唯一的解決辦法就是從家裏下載文件,並將其放入USB密鑰中。 – HAL9256

回答

1

這是內部網絡代理,因爲某些原因,在傳輸81.4 MB(85,363,075字節)之後丟失請求。但奇怪的是webclient沒有拋出任何異常,並假裝下載成功。

解決方法是將代理空值,以便在不通過代理的情況下處理請求。

$client.proxy=$null # get rid of proxy 
$client.DownloadFile($Url, $destination)