delete_files_older_than
This is an old revision of the document!
You can use the Get-ChildItem cmdlet to retrieve the files, and the Where-Object cmdlet to filter the files based on their age. You can then use the Remove-Item cmdlet to delete the filtered files
#Get All Files modified more than the last 90 days Get-ChildItem -Path C:\path\to\folder -Recurse -File | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-90) } | Remove-Item –Force -Verbose
Get-ChildItem C:\inetpub\mailroot\Badmail.old -Recurse -File | Where {$_.CreationTime -gt (Get-Date).AddDays(-90)} | Remove-Item -Force
delete_files_older_than.1676841530.txt.gz · Last modified: 2024/10/17 21:42 (external edit)
