User Tools

Site Tools


delete_files_older_than

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
delete_files_older_than [2023/02/19 21:18] – created osodelete_files_older_than [2024/10/17 21:42] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
 <code powershell> <code powershell>
-#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 -Path C:\path\to\folder -Recurse -File | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-90) } | Remove-Item –Force -Verbose
 </code> </code>
  
 <code powershell> <code powershell>
-Get-ChildItem C:\inetpub\mailroot\Badmail.old -Recurse -File | Where {$_.CreationTime -gt (Get-Date).AddDays(-90)} | Remove-Item -Force+Get-ChildItem -Path C:\inetpub\mailroot\Badmail -Recurse -Force | Where-Object !$_.PSIsContainer -and $_.CreationTime -lt (Get-Date).AddDays(-30) } | Remove-Item -Force -Verbose
 </code> </code>
delete_files_older_than.1676841530.txt.gz · Last modified: 2024/10/17 21:42 (external edit)