用于复制按大小排序的文件的PowerShell脚本

用于复制按大小排序的文件的PowerShell脚本,powershell,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 th

在早上运行的脚本中,我需要将文件从一台服务器复制到另一台服务器,我计划先复制更大的文件,并且这样做了:

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.
我应该怎么做才能使它工作?

这应该工作:

Get-ChildItem | sort -property Length -Descending  | Select -ExpandProperty FullName | Copy-Item -Destination $LOCAL_BKP_FINAL
这应该起作用:

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

无需展开全名,因为复制项应将其作为valuefrompipelinebypropertyname接受。无效。返回错误:“复制项:无法将输入对象绑定到该命令的任何参数,因为该命令不接受管道输入,或者输入及其属性与接受管道输入的任何参数都不匹配。”有人可以建议另一个选项吗?不要将
$LOCAL\u BKP\u TEMP\*
添加到您的
copy item
命令中,这就是导致错误的原因它起作用了!老实说,我没有意识到不在copy item命令中添加$LOCAL_BKP_TEMP\*的细节。非常感谢。无需展开全名,因为复制项应将其作为valuefrompipelinebypropertyname接受。无效。返回错误:“复制项:无法将输入对象绑定到该命令的任何参数,因为该命令不接受管道输入,或者输入及其属性与接受管道输入的任何参数都不匹配。”有人可以建议另一个选项吗?不要将
$LOCAL\u BKP\u TEMP\*
添加到您的
copy item
命令中,这就是导致错误的原因它起作用了!老实说,我没有意识到不在copy item命令中添加$LOCAL_BKP_TEMP\*的细节。非常感谢。