:::: MENU ::::

Powershell delete old backups/files

Can be run in a SQL Agent job as a powershell jobstep.

This script deletes bak and trn files in all subcatalogs under Y:\Backup that are older then 1 day. Modify after needs.

Get-ChildItem 'Y:\Backup' -include *.bak,*.trn -Recurse | Where {$_.creationtime -lt (Get-Date).AddDays(-1)} | Remove-Item -Force

//Richard


So, what do you think ?