Hello, I’ve been working on a personal project for over a month now and I am running into a problem.
Basically, I 'd like to have .txt file less than seven days old to be move to a different drive on Sundays. Using Task Scheduler, I’ll have the action run a script I’ve made for PowerShell ISE. The problem is, the script is pulling all .txt files regardless of age. I need only the most recent (7) days. Here is what I’ve come up with doing my own research. I appreciate any help. Thanks!
get-childitem -Path N:\Fake\Source\Location*.txt |
Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(7)} |
copy-item -Destination ‘\Storage\Destination\Test’