Skip to content

Instantly share code, notes, and snippets.

@tcshao
Last active October 11, 2015 03:38
Show Gist options
  • Select an option

  • Save tcshao/3797240 to your computer and use it in GitHub Desktop.

Select an option

Save tcshao/3797240 to your computer and use it in GitHub Desktop.
Deleting *.txt files from 'c:\temp' and subdirectories more than 5 days old
<# Deleting *.txt files from 'c:\temp' and subdirectories more than 5 days old #>
Get-ChildItem 'C:/temp' -Recurse -Include '*txt'
| WHERE { ($_.CreationTime -le $(Get-Date).AddDays(-5)) }
| Remove-Item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment