Powershell : Delete Old Files

One of the more important tasks when installing Biztalk, in Prod or in any other environement is to set the proper backup procedure. So Coonfiguring the SQL jobs for the backlup is easy, but the other task is cleaning up the backup after a few days. (Without using the SQL command line utility for security reasons)

Powershell script :

1
Get-ChildItem "D:\DATA\Backups" -Recurse -File | Where CreationTime -lt  (Get-Date).AddDays(-3)  | Remove-Item -Force

Scheduled task : 1 Set the rights to execute script in powershel : -

1
PowerShell -ExecutionPolicy Unrestricted -File "D:\DATA\CleanOldFiles.ps1"

2 create task