我想使用PowerShell将大量文件从Windows系统复制到Unix共享。我似乎能够得到这么多,但不是整个解决方案。在PowerShell中使用Get-ChildItem复制项目
我似乎能够复制文件,只要我不介意它们存储在哪里,因为它失去了所有的文件夹结构。我尝试过在这里和其他地方发布的各种方法无济于事。
代码:
gci -path "e:\company folders\\*" | Where-Object {$_.LastAccessTime -le (Get-Date).addyears(-2)} | Copy-Item -destination "\\\networkfolder\archive\company folders\"
我已经试过这个脚本的几个变化,包括使用-recurse的-path后和-destination
后最成功的
gci -path "e:\company folders\*" | Where-Object {$_.lastaccesstime -le (Get-Date).addyears(-2)} | Copy-Item -destination "\\\networkshare\archive\company folder\" -recurse -container
来到
但是这只复制了43个文件夹中的5个..
什么我做错了吗?
如果你启动一个需要很长时间或传输大量文件或删除大量文件的进程,我建议你使用-whatif操作。这会告诉你如果你去执行命令会发生什么。例如:Get-Childitem C:\ SomeFile \ *。txt -Recurse | Remove-Item -WhatIf .....在你看到脚本会做什么之后,你就知道脚本是否是错误的,或者仅仅因为它的负载太大而停止。 – RayofCommand
非常复制http://stackoverflow.com/questions/11694961/whats-the-proper-way-to-copy-files-while-preserving-folder-structure-in-powersh/11695329#11695329 – SpellingD