BizTalk Bindings Exportation: How to Export BizTalk Server Bindings by a List of Port Names with PowerShell

Published on : May 28, 2019

Category : BizTalk Server



Finally, the last blog post on this series about BizTalk Bindings Exportation with PowerShell:

Today’s blog post will be about: How to Export BizTalk Server Bindings by a List of Port Names with PowerShell.

In other words, instead of generating a specific binding file for each port: Receive Port and/or Send Port, we will include all of the receive ports and send ports bindings in a unique binding file, so it can easily be handled.

This functionality should be something that should exist in the BizTalk Server Administration Console, but it is impossible to be addressed using the out-of-the-box tool BizTalk Server Administration Console or even with the BTSTask command-line tool which is included with BizTalk Server.

As always, and like the previous samples, we could fully automate this Binding generation for each environment, but once again let’s keep it simple. With this PowerShell sample, we will be able to generate a unique binding file for a list of specific assemblies deployed in my BizTalk Server environment. The script will perform the following tasks:

  • Generate a Binding file for 3 environments DEV, QA and PRD
  • Generate a unique binding file, instead of having separated binding files for each Port name (receive port and/or send port)
function bts-list-ports-exportbindings([string]$bindingFilePath, [string]$bindingNamePrefix, [string]$appName, [string]$rcvPortNames, [string]$sndPortNames, [boolean]$generateDiffEnvBindings)
    $finalBinding = [xml](Get-Content "C:\Temp\BTS\TemplateBindingInfo.xml")
    $moduleRefNode = $finalBinding.SelectSingleNode("BindingInfo/ModuleRefCollection")
    $sendPortNode = $finalBinding.SelectSingleNode("BindingInfo/SendPortCollection")
    $receivePortNode = $finalBinding.SelectSingleNode("BindingInfo/ReceivePortCollection")

    $listRcvPorts = $rcvPortNames.Split("|")
    $listSndPorts = $sndPortNames.Split("|")

    $taskParams = ” ExportBindings /Destination:$bindingfilePath$appName.BindingInfo.xml /ApplicationName:$appName ”
    Start-Process "BTSTask.exe" $taskParams -Wait

    $xml = [xml](Get-Content "$bindingfilePath$appName.BindingInfo.xml")

    foreach($receivePortBinding in $xml.BindingInfo.ReceivePortCollection.ReceivePort)
        if($listRcvPorts -Contains $receivePortBinding.Name)
            $node = $finalBinding.ImportNode(($receivePortBinding), $true);

    foreach($sendPortBinding in $xml.BindingInfo.SendPortCollection.SendPort)
        if($listSndPorts -Contains $sendPortBinding.Name)
            $node = $finalBinding.ImportNode(($sendPortBinding), $true);




We will not change the URI for each environment – it could be done, but is not the goal here, it is just a start.

You can download the full script from here: Export BizTalk Server Bindings from a List of Port Names with PowerShell