In this example, I will create a powershell command to delete files not modified in the last 30 days from a shared folder:

 

Get-ChildItem -Path \\SERVER\SHARE | ? {$_.LastWriteTime -le (get-date).AddDays(-30)} | Remove-Item -Include $()
  • Change the Path value to the server path
  • Change the -30 value to the desired number of days

 

blog comments powered by Disqus