Tuesday, September 7, 2021

Delete files older than 30 days

 I have this come up from time to time so I thought I'd go ahead and post the one-liner.


gci | Where-Object {$_.LastWriteTime -lt  (get-date).AddDays(-30)}


Send that to a Remove-Item and you are set. 

No comments:

Post a Comment