I am trying to get a working PS script that backs up most recent data dating back to 15 days, I want to have it scheduled to run every 15 days. I am backing up .tiff images but they are created daily in structured folders with a date on each folder. After the 15 days, I want to delete the backed up data so that its all new data every 15 days.
Writing this, I think it's easier to run it daily to backup and delete data 15 days back, so every day it deletes and copies only 1 day.
Who can help me with this task? This is what I got so far..
Powershell
Functioncopy{#Moves all files Newer than 15 days old from the Source folder to the TargetGet-Childitem-Path"C:\Files\Folder\"|Where-Object{$_.LastWriteTime-gt(get-date).AddDays(-15)}|ForEach{Copy-Item$_.FullName-destination"\\MTS.dom\Test\"-force-ErrorAction:...