Move Files older then 31 days to another drive

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
  }
}

in the source directory are files that are older than 2-3 years, but when i run the script nothing moves to the target directory ?! whats wrong ?

12
задан Jamiec 6 May 2011 в 13:28
поделиться