我是新來的PowerShell腳本,我不知道爲什麼我的腳本複製 所有文件,似乎並沒有檢查日期,然後複製無論如何,所有文件 。我正在嘗試做幾天和幾分鐘,但我不太確定 如何做到這一點。任何幫助將是偉大的!Powershell腳本複製文件基於日期modifed從遠程位置檢查最新的文件
see my script below.
$RemotePath = "\\eb-pc\E$\testlocation\*.txt"
$LocalPath = "C:\testlocation"
$Max_days = "-1"
#Max_mins = "-5"
$Curr_date = get-date
#Checking date and then copying file from RemotePath to LocalPath
Foreach($file in (Get-ChildItem $RemotePath))
{
if($file.LastWriteTime -gt ($Curr_date).adddays($Max_days))
{
Copy-Item -Path $file.fullname -Destination $LocalPath
#Move-Item -Path $file.fullname -Destination $LocalPath
}
}
非常感謝您的幫助! – 2015-04-03 12:50:35