2015-02-11 73 views
0

我配置了IIS服務器,它現在在localhost上運行。我需要藉助Powershell命令行工具下載IIS目錄中的文件。使用powershell命令行開關從網站下載(使用BITS傳輸)

我試過後臺智能傳輸服務.. 像

啓動BitsTransfer -Asynchronous -Priority高-TransferType下載 - 源http://localhost/vdir/validity.txt -Destination C:\

它沒有給予任何錯誤執行罰款 但文件沒有下載 像m獲得位傳輸狀態爲「TRANSFERRED」,但文件沒有得到下載..任何想法,爲什麼它如此.. :(

+0

嘗試'啓動BitsTransfer'與'-Verbose'或'-Debug'參數 – 2015-02-11 09:59:52

+0

使用'-Verbose'或'-Debug'參數 – 2015-02-11 10:00:04

回答

0

可能是因爲-Asynchr onous標誌要求Complete-BitsTransfer cmdlet才能完成傳輸。

例如。 如果你運行像

Start-BitsTransfer -Asynchronous -Priority High -TransferType Download -Source http://localhost/vdir/validity.txt -Destination C:\ 

那麼你的代碼,我想你會對你的C一些xxxx.tmp文件:\根。當你的BITS作業的狀態會像

JobId    : **3bdb9071-d780-446f-974c-074a48206c0c** 
DisplayName   : BITS Transfer 
TransferType  : Download 
JobState   : **Transferred** 
OwnerAccount  : blablabla 
Priority   : High 
FilesTransferred : 1 
FilesTotal   : 1 
BytesTransferred : 310764 
BytesTotal   : 310764 
CreationTime  : 2/23/2015 3:55:23 PM 
ModificationTime : 2/23/2015 3:55:39 PM 
MinimumRetryDelay : 
NoProgressTimeout : 
TransientErrorCount : 0 
ProxyUsage   : SystemDefault 
ProxyList   : 
ProxyBypassList  : 

然後,你將需要運行以下命令來獲取xxxx.tmp文件轉換爲validity.txt

$Job = Get-BitsTransfer -JobId "3bdb9071-d780-446f-974c-074a48206c0c" 
Complete-BitsTransfer -BitsJob $Job 
+0

嘗試'Start-BitsTransfer'是否有使用異步BITS傳輸的優點? – 2015-02-24 14:40:58

+0

是的。在異步模式下,傳輸將在網絡故障或其他情況下自動恢復。 實際上,異步模式意味着傳輸將作爲後臺作業添加。同步模式就像通常的手動複製操作一樣。 – 2015-02-25 08:48:06