BizTalk PowerShell script

How to update Authentication Credentials on BizTalk Server Send Ports with PowerShell

Published on : Oct 22, 2020

Category : BizTalk Server

Sandro

Author

With security be every day more important, this also brings additional problems (good problems) to BizTalk Server Administrators during the deployment of new BizTalk Server Applications or even during the lifecycle of existing applications:

  • What a few years ago was anonymous, because they were internal services, they are now authenticated
  • Nowadays, many organizations implement a combination of Minimum Password Age policy also enforcing a Password History policy that requires to reset the password, even for service accounts, from time to time and avoid reusing the same password

These tasks lead to BizTalk Server Administrators having to manually set the user credentials in a range of ports (send and receive). This is not always a quick and easy job.

Luckily for us, these tasks can be automated, leading them to become simpler, faster, and avoid fewer errors.

PowerShell script overview

With this PowerShell sample, we will be able to set or update the Authentication Credential on a list of BizTalk Server Send Ports deployed in your BizTalk Server environment.

foreach($SendPort in $catalog.SendPorts)
{
    # In this case ...
    if($sndPorts.Contains($SendPort.Name))
    {
        [xml]$bindingConfiguration = $SendPort.PrimaryTransport.TransportTypeData
        if($bindingConfiguration.CustomProps.Password.vt -eq "1")
        {
            $bindingConfiguration.CustomProps.Password.InnerText = "my_password"
            $bindingConfiguration.CustomProps.Password.vt = "8"
        }
        else
        {
            $passwordElement = $bindingConfiguration.CreateElement("Password")
            $passwordElement.SetAttribute("vt", "8")
            $passwordElement.InnerText = "my_password"
            if($SendPort.PrimaryTransport.TransportType.Name -eq "FILE")
            {
                $bindingConfiguration.CustomProps.InsertAfter($passwordElement, $bindingConfiguration.CustomProps.CopyMode)
            }
            else {
                $bindingConfiguration.CustomProps.InsertAfter($passwordElement, $bindingConfiguration.CustomProps.EnableTransaction)
            }
            
        }
        if($bindingConfiguration.CustomProps.UserName.vt -eq "8")
        {
            $bindingConfiguration.CustomProps.UserName.InnerText = "my_username"
        }

        $transportConfigData = $bindingConfiguration.InnerXml
        $SendPort.PrimaryTransport.TransportTypeData = $transportConfigData
    }

This script was tested in:

  • BizTalk Server 2020
  • BizTalk Server 2016

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

Download

You can access and download the full PowerShell script from GitHub here: Set Authentication Credential on BizTalk Server Send Ports with PowerShell