$date = N - удаляем файлы старше N дней
$path - сами догадаетесь
Если удалить Whatif - будет и вправду удаляться.
$date = 30
$path = "C:\log"
Get-ChildItem $path | where {$_.lastwritetime -le ((get-date).AddDays(-$date))} | Remove-Item -Whatif
$date = N - удаляем файлы старше N дней
$path - сами догадаетесь
Если удалить Whatif - будет и вправду удаляться.
$date = 30
$path = "C:\log"
Get-ChildItem $path | where {$_.lastwritetime -le ((get-date).AddDays(-$date))} | Remove-Item -Whatif
Комментариев: 2 RSS
1 иуан 18-09-2015 21:58
Чтобы не задавал вопрос на удаление добавить в конце -Force -Recurse
2 Kinzersky 05-11-2015 18:56
Благодарю )