Afternoon,
I have been trying to roll my own ps script to accomplish a cleanup task but I am rather new to ps and am not getting the results I am needing.
Here are the criteria I am shooting for:
1. Target file type will be BAKs
2. Needing to be purged BAKs that are 7 days old
3. Target backup folder that is addressed via a UNC looks something like \\MyMainBackupFolder\ServerName\Backups
4. Under the Backups folder are several folders which correspond to each database on my instance.
What I am trying to achieve is to have a script embedded as a step in a SQL job that I can pass the following parameters to:
-targetpath
-days
- extension
and then have the ability to output the execution of purging the files (with the file names included) out to a text file let’s say is named C:\FilesDeleted.
If needed I can post what I have so far but if there is already a script someone already has for this function I would appreciate being pointed towards it.
Thanks!