OK、フォルダと内容を日付に基づいてUNCパス(共有ドライブ)から別のUNCパス(NAS)にコピーしようとしています(2015年1月1日前)。はい、私はコードが2017と言うことを知っていますが、テストで作業したら、日付を変更してprodで実行します。Powershellでフォルダとコンテンツを移動します。
#Original file path
$path = "UNC Path"
#Destination file path
$destination = "Different UNC Path"
#It makes a filelist of what's inside the $path path
Foreach($file in (Get-ChildItem $path)) {
#If the lastwrite time is before the given date
If($file.LastWriteTime -lt "01/01/2017") {
#It copies the file to the destination
Copy-Item -Path $file.fullname -Destination $destination -Force } }
フォルダの内容は正常にコピーされますが、フォルダはコピーされません。私は〜が間に合わないと思っていますが、Get-ChildItem $パスの後に置くと動作しませんでした。
私はこの作業をし、次にRemove-Item行を追加して、ファイルサーバーからすべての古い項目を削除する予定です。
思考?これを達成するためのより良い方法の提案?
おかげで、
ちょうど開始が、二つのことだrobocopyを –