Powershell : Calling BTSTask.exe
I set out to write a bunch of PS functions to manage Biztalk to keep in a little script library that i could then call from external scripts etc (I found and came up with some other good stuff that i’ll share shortly but this is something i had to write about immediately).
One of the tasks was to export bindings for an application. This is something that i found incredibly hard to do from within a function. It works alright when just called interactively, just like any normal command prompt, but invoking the process within a function had me lose a lot of hair (and theres very little spare anyway 😦 ).
Anyhow, i’ll spare you the gory details. After mucking around with System.Process, trying to capture the output window , invoking cmd etc, the solution was drop dead simple.
A snippet of the function is as follows
function bts-application-exportbindings ([string]$bindingFile, [string]$appName)
$taskParams = ” ExportBindings /Destination:$bindingfile /ApplicationName:$appName ”
$p = [diagnostics.process]::start(“BTSTask.exe”, $taskParams)
Thats all. But my goodness, it had me really frustrated for a while. C’est la vie!! Hope it helps some of you…