Delete discarded messages from local folders using PowerShell

  • Sandro Pereira
  • Jul 21, 2021
  • 2 min read

This is such a common task on BizTalk Server that I have already forgotten 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 to specific messages to be discarded in a folder. Otherwise, they will get stuck on the administration console, and we don’t want that.

📝 One-Minute Brief

Use a PowerShell script to delete discarded BizTalk messages from local folders to prevent slowdowns and avoid disk space issues.

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 makes 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 the Delete Discarded messages from local folders PowerShell script from GitHub here:

Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son. 

Thanks for Buying me a coffe
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 *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top