Powershell script to delete old files
- by yantwill
The following script will delete files in a named directory that are older than 14 days and write to a .txt with the path and the files deleted (found this script on another forum..credit to shay):
dir c:\tmp -recurse | where {!$.PsIsContainer -AND $.lastWriteTime -lt (Get-Date).AddDays(-14) } | select LastWriteTime,@{n="Path";e={convert-path…