michelgentile revised this gist 2 months ago. Go to revision
No changes
michelgentile revised this gist 2 months ago. Go to revision
1 file changed, 5 insertions
script.ps1(file created)
| @@ -0,0 +1,5 @@ | |||
| 1 | + | #Remove files older than... | |
| 2 | + | Get-ChildItem -File -Recurse | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-180) } | Remove-Item -Force | |
| 3 | + | ||
| 4 | + | #Remove empty folders (may be repeated up to X times...) | |
| 5 | + | Get-ChildItem -Directory -Recurse | Where-Object { -not (Get-ChildItem -Path $_.FullName -Recurse -Force -ErrorAction SilentlyContinue) } | Remove-Item -Force | |
Newer
Older