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

Download

THIS POWERSHELL SCRIPT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.

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

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published. Required fields are marked *

turbo360

Back to Top