Delete discarded messages from local folders using PowerShell

This is a so common task on BizTalk Server that I already forgot how many times I did it. Depending on several scenarios, like:

  • Testing
  • Certain parts of the application are not yet ready to production
  • Or even discarded unwanted messages

We want/need to create a send port and subscribe specific messages to be discarded on a folder. Otherwise, they will get stuck on the administration console, and we don’t want that.

After a while, the problem is that the folder will get a considerable amount of messages, and writing a large number of files to disk will get progressively slower as the number of files in the target directory gets large. This is because your computer’s operating system must keep track of all files in a directory. Even bulk deleting all of these files will take a longer time. Moving or deleting files from the target directory on a regular basis will ensure that the performance is not adversely affected.

A large number of small files make more impact than a small number of large files, and most of the time, BizTalk Server consumes/produces small messages. However, at some point, you may completely fill the hard drive, which is more critical.

With this script, you can easily configure the folders and the type of files you want to monitor and delete.

Get-ChildItem -Path C:Temp -Include *.* -File -Recurse | foreach { $_.Delete()} 

This will help BizTalk Administrators to take full control of their environments



You can download Delete Discarted messages from local folders PowerShell script from GitHub here:

The post Delete discarded messages from local folders using PowerShell appeared first on SANDRO PEREIRA BIZTALK BLOG.