I wrote a script that moves files older than two days over to a network share (via scheduled task). Windows Task Scheduler doesn't seem to like the script so much, but it works well by itself.
Is there a faster way than what I have?
Is there a way to programmatically make it a scheduled task or service of some type?
Backup.ps1
$today = get-date
$tda= $today.addDays(-2) #two days ago
$files = get-childitem d:\source_path | select fullname, lastwritetime | where-object{$_.lastwritetime -lt $tda}
foreach ($file in $files) {
Echo "moving " $file.fullname #just so I know it's still running, get rid of this?
mv $file.fullname 'n:\dest_folder'
Echo 'done'
}