> Get-ChildItem | Where-Object{$_.CreationTime –lt (Get-Date).AddDays(-30)} | Remove-Item
Want to clear out the current directory AND all subdirectories? Add the -Recurse flag after Get-ChildItem.
> Get-ChildItem -Recurse | Where-Object{$_.CreationTime –lt (Get-Date).AddDays(-30)} | Remove-Item
Want to suppress any "are you sure" prompts? Add the -Recurse flag after Remove-Item.
> Get-ChildItem -Recurse | Where-Object{$_.CreationTime –lt (Get-Date).AddDays(-30)} | Remove-Item -Recurse
No comments:
Post a Comment