I am really good at reinventing the wheel! Most of the time the wheel isn’t even better – just more complicated. Back in May, I posted a script that to clean up old files. I used this on Windows Server 2003 box for a few years and moved it to a 2012 R2 server. The script used PowerShell and basically compared the LastAccessTime attribute to some date. A reader named Jeff took one look at my script and basically said, “Joseph – just use File Management Tasks”.

And Jeff was right! File Management Tasks are easier to setup and provide a lot more flexibility out of the box. Today, let’s look at how the File Server Resource Manager can keep our shares clean of old data!

Configuring a File Management Task

First, your file server does have to be running Windows Server 2008 R2 or higher. For those of you kicking it old school, I’ll wait while you upgrade. 🙂

Next, add the File Server Resource Manager role to your server. Accept the defaults during the installation.

Under the Action tab, ensure that Type is set to File Expiration. When a file is marked to expire (more on that in a bit), it is never deleted. Instead, it is moved out of the scope (C:\public in the screenshot above) and into your expiration directory. Don’t worry about accidently deleting files because you can’t do it! In the screenshot below, I am moving expired data to a local folder.

Select the Condition tab. In this window, you can set criteria for what files are considered stale. By creation multiple tasks for different scopes, you can have more restrictive or aggressive cleanups as needed. Each check box functions as an AND statement. Our conditions below ensure that files are not moved they haven’t been modified for 3 years and haven’t been accessed for two years.

If desired, you can use the Notification tab to alert users of pending changes. In your notification, you can include a list of files that will be removed and provide additional instructions to your staff on what they should do. You can use the Report tab to email IT staff members a list of changes after a task has completed.

For your task to run, it must have a schedule. Press the Schedule Tab – then Edit. I recommend a schedule of once per month at the most. You can run it now for testing or wait until the schedule. As it is running, you can watch your Expired Files Directory populate. To make restoration easier, the files are moved to the expired directory using their previous folder structure. From here, you can schedule a permanent deletion by using a schedule task to empty the folder. You can also use this PowerShell script:

Were you able to figure this out? I have the same issue. Running it on Windows Server 2016. Ran the task on a test folder and it moved the older files out to the expiration directory keeping the directory structure however the old folders in the original directory are still there. It never deleted the older folders so I now have all these empty folders. The oddest part is now all of the folders have a new creation date of when the task ran.

Hi,
I’m trying to implement this to keep some backup files under control. We only need to keep a weeks worth of zip files but it’s not moving the files on test runs. I’ve tried various conditions and I can see in the little report tree at the bottom of the MMC while it runs that it processes 15 files (the amount in the directory) but for some reason its not moving the files. Any ideas at all?

Thanks for getting back. Unfortunately, no 🙁 It runs but never moves any files. I’ve tried various conditions combinations and it ‘processes’ the files but never shifts them over. Are there any specific permissions I need to be aware of? Haven’t really found much that’s been useful to me on my searches so far!

Hi,
I have configured quoata with File Server Resource Manager, but when i test send email i have error:
Relay denied proper adhentification required.
I have an another server that send quota email, i tested it with this smtp that not working in the first server.
This work fine with the second.
i think there a service or role that must be instaled in the frist server to be able to send email.!!
Thanks

Thanks, for this post from…a year ago. I was wondering if there is a way to have exemptions in the purge. So, if I have a Users share with folders for Peter, Paul, Mary and Joe, and Joe is a hoarder, how can I exclude his folder and files? Can I still set it up on the Users share or now do I have to do it individually on Peter, Paul and Mary?
Thanks,
Matt

Thanks for you response… I think I figured out a way, but, still need to test it. I will try creating Classification-Ordered Lists and then setup the Management Tasks based on the Classification Property Conditions. So Low properties will purge after 2 years, Medium after 7, and High never. I hope I made sense. And, I hope it works.

What kind of actions can you perform from here? I’m envisioning leveraging this with some sort of Powershell script that moves the files to an equivalant folder on an “Archive” file server on slower storage.

Glad you found it! We also use it for monitoring shares for the presence of things like MP3/AVI and other “non-business” related files. You can use it in sneaky mode (report only) or full on agressive (prevent them saving).
We also have it applying quota’s to user home folders, warning them when they’re getting close, granting a temporary extension and then applying a hard quota.