Let’s face it, logs are everywhere.  It seems like every piece of software creates log files these days.  Unfortunately, not every piece of software cleans up after itself or allows setting limits on the amount of logging to create and retain.  This can bring down a system if log file storage is not kept in check.


The following PowerShell script will prune log files older than 60 days.  Modify the $DaysToKeep variable to change how many days worth of logs are kept.  At the bottom of the script, initiate the PruneLogFiles function with the folder(s) to prune.  Finally, use the Windows Task Scheduler to create a scheduled task.  Personally, I run the script weekly.  Enjoy!