How many times have you wrote a ‘quick script’ to clean up or archive log or temp files on a Windows-based machine?  Or worse yet, you’re constantly get called or texted because of some production running out of disk space due to logs. Yeah, me too.

I just deployed another group of systems in the last couple of weeks – one that creates log files for every single action done (ugh.)  I finally got tired of creating just another script for another system deployed to maintain these free-time invaders. So I sat down and wrote a generic PowerShell script that was configurable enough to handle a number of situations.

The Move-FilesToArchive script used an XML file for configuration information like source directory, archive directory, which archive action is desired.  The script can move, delete, or zip up files.  Each configuration file can perform one action.  If you create a couple of scheduled tasks, you can have a multi-level archiving process.  For instance, one to zip files older than a week, and another to delete zip files older than 3 months.

Instead of posting the code on this blog – I’ve decided to use GitHub for code that I’m sharing.  That way I don’t have to worry about updating a blog page every time I make an edit to the script file.

In any event, you can find the Move-FilesToArchive here: