Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ergunozyurt/5487132 to your computer and use it in GitHub Desktop.
Save ergunozyurt/5487132 to your computer and use it in GitHub Desktop.
# set folder path
$dump_path = "d:\temp"
# set min age of files
$max_days = "-1"
# get the current date
$curr_date = Get-Date
# determine how far back we go based on current date
$del_date = $curr_date.AddDays($max_days)
# delete the files
Get-ChildItem $dump_path -Recurse | Where-Object { $_.LastWriteTime -lt $del_date } | Remove-Item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment