PowerShell Script to Clean Up Files Older than X Days

$purgePeriod = 30;

$folders = '\\FILSERVER01\ORDERS\BACKUP','C:\SFTP_BACKUP';

Get-ChildItem -path $folders | where {$_.Lastwritetime -lt (date).adddays(-$purgePeriod)} | remove-item;

Leave a Reply

Your email address will not be published. Required fields are marked *