Forum

powershell - select...
 
Powiadomienia
Wyczyść wszystko

powershell - select files modified X hours ago and copy them

1 Wpisy
1 Użytkownicy
0 Reactions
953 Widoki
0
Rozpoczynający temat

example script, ps1

1 odpowiedź
0
Rozpoczynający temat
#select files older than 2 hours
$date = Get-Date
$start_date = $date.AddHours(-2) 

#cleanup destination directory
Remove-Item MY_DESITNATION_DIR* -Recurse

#copy
Get-ChildItem -Path Backup -File |
    Where-Object { $_.LastWriteTime -gt  $start_date } |
    ForEach-Object {
        Copy-Item -Path MY_SOURCE_DIR$_ -Destination 'MY_DESITNATION_DIR' 
    }

Twoja odpowiedź

Nazwa autora

E-mail autora

Twoje zapytanie *

Podgląd 0 rewizje Zapisano
Udostępnij: