Function Move {
#Moves all files older than 31 days old from the Source folder to the Target
Get-Childitem -Path "E:\source" | Where-Object { $_.LastWriteTime -lt (get-date).AddDays(-31)} |
ForEach {
Move-Item $_.FullName -destination "F:\target" -force -ErrorAction:SilentlyContinue
}
}在源目录中有超过2-3年的文件,但是当我运行脚本时,没有任何东西移动到目标目录?!怎么了?
发布于 2012-06-06 22:17:26
也要注意隐藏文件,尝试在Get-ChildItem中添加-Force
https://stackoverflow.com/questions/5912051
复制相似问题