我公司开发的PowerShell脚本,它的工作绝对没问题。 唯一的挑战是在子文件夹中的文件都没有得到移动到目的地。
get-childitem -Path "\\servername\location" |
where-object {$_.LastWriteTime -lt (get-date).AddDays(-31)} |
move-item -destination "C:\Dumps"
我无法进一步自定义脚本。
我公司开发的PowerShell脚本,它的工作绝对没问题。 唯一的挑战是在子文件夹中的文件都没有得到移动到目的地。
get-childitem -Path "\\servername\location" |
where-object {$_.LastWriteTime -lt (get-date).AddDays(-31)} |
move-item -destination "C:\Dumps"
我无法进一步自定义脚本。
使用-Recurse
的选项Get-ChildItem
命令打通文件的子文件,然后通过管道收集到移动每个单独Move-Item
Get-ChildItem -Path "C:\Test" -Recurse |
Where-Object {$_.LastWriteTime -lt (Get-date).AddDays(-31)} |
Move-Item -destination "C:\Dumps"
下面是截图:
不要浪费你的时间试图重新发明robocopy
在PowerShell中。
robocopy \\servername\location C:\Dumps /e /mov /minage:31
上述的简化
robocopy A:\ B:\ /MIR /minage:31
其中A:\是您的源B:\是您的目的地
我需要一个快速班轮要将所有数据从一个驱动器到另一个。 这完全为我工作:
GET-ChildItem “E:” -Recurse | 布展项目-Destination“G:”