2015-12-30 77 views
0

命令文件在運行的早晨,我需要從一個服務器複製到另一個文件的腳本,我打算先複製大文件,這樣做:PowerShell腳本複製按大小

Get-ChildItem | sort -property Length -Descending | Copy-Item $LOCAL_BKP_TEMP\* -Destination $LOCAL_BKP_FINAL -PassThru 

給出以下錯誤:

Copy-Item : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input. 

我應該怎麼做才能使它工作?

回答

3

這應該工作:

Get-ChildItem | sort -property Length -Descending | Select -ExpandProperty FullName | Copy-Item -Destination $LOCAL_BKP_FINAL 
+0

有沒有必要擴大全名,因爲複製的項目應該接受它作爲valuefrompipelinebypropertyname。 – Kiran

+0

沒有工作。返回的錯誤:「Copy-Item:輸入對象不能綁定到該命令的任何參數,因爲該命令沒有采用流水線輸入,或者輸入及其屬性 與任何採用流水線輸入的參數都不匹配。 –

+0

有人可以提出另一種選擇嗎? –