Powershell script to delete files in a folder based on age
Posted on 2015-02-11
I need a powershell script to perform the following:
1. Determine the size a particular drive
2. If free-space is less than say 10% then delete oldest .csv files from specific directories
System Event log files are archived as csv files for specific event types...Application, security, etc. The path is something like e:\Saved_logs\Application; e:\Saved_logs\Security; etc. Each of these subfolders contain csv files that contain a servername-timestamp.csv file
(ex: servername-01012015-midnight.csv). There may be 20 files covering 20 servers for a particular time frame. The idea is, if the the freespace of the volume is less than 10% then search in each of these subfolders and delete the oldest files by date.