BizTalk Server Send Port

How to restart a BizTalk Server Send Port with PowerShell/BizTalk360

Published on : Jun 24, 2022

Category : BizTalk Server



Similar to our previous post “How to restart a BizTalk Server Receive Location with PowerShell/BizTalk360”, restarting a send port on a scheduled basis is sometimes a common workaround to solve third-party adapter issues or even with out-of-the-box adapter issues like the SFTP adapter, especially in old BizTalk Server versions, or because of external systems/tools.

Another reason to stop send ports on a scheduled basis is for planned external systems interventions. For example, we know that on the first day or on the last day of each month our external system is down for maintenance, We don’t want to stop the send host instance (except if it is a dedicated host instance just for that set of send ports) because that will affect all send ports that are bound to that host instance. So, a good solution is to stop the Send Port for that period of time or restart the Send Port depending on your requirement.

In this sample, we will address the restart capability by using PowerShell but you can of course modify this script or divide this script to implement the downtime feature capability to address external systems interventions.

This is something you can do by using BizTalk360 and many customers are actively using it, but that doesn’t mean that you cannot use this PowerShell script. Actually, BizTalk360 allows you to extend its out-of-the-box capabilities by allowing you to integrate PowerShell scripts with BizTalk360.

Of course, to use this script on a scheduled basis, you need to use it inside BizTalk360 or you can create a Task Scheduler on the BizTalk Server machine or any other machine with access to BizTalk Server.

Side note: if you want to control system downtime interventions by stopping the send ports and after a certain period of time starting the ports, this will be way easier to achieve by using BizTalk360 .

PowerShell to Restart a BizTalk Server Send Port

With this script, we can accomplish exactly that: Restart a Send Port by using PowerShell.

The function below accepts the send port name and guarantees that a “restart” is made. In reality, there isn’t a restart operation, instead, we need to stop it, and then when it is successfully stopped we will start it once again.  If the Send Port is already stopped, the script will continue and it will make sure that it will start the port. 

function restart-send-port (
    # Get the Send Port by name
    $port = get-wmiobject MSBTS_SendPort -Namespace 'root\MicrosoftBizTalkServer' -Filter "name='$sendPort'"

    #Stop the send port

    #Loop to check and guarantee that the send port was successfully stopped
    #Sometimes this can take a few seconds depending on the workload that BizTalk Server is processing
    #So this loop is here for security to guarantee the enable operation will be triggered only when the port is stopped.

        $port = get-wmiobject MSBTS_SendPort -Namespace 'root\MicrosoftBizTalkServer' -Filter "name='$sendPort'"
        if($port.Status -ne 2) {
            Start-Sleep -s 10

    } While ($port.Status –ne 2)

    #Start the Send Port


You can download How to restart a BizTalk Server Send Port with PowerShell from GitHub here:

Use BizTalk360 to restart a Send Port

At the time of writing, the BizTalk360 team is working on v10.3. An important feature of that release will be the Automated Tasks feature. This will allow you to stop/start/restart ports, orchestrations, BizTalk host instances, and logic apps on a scheduled basis.

See below, a couple of screenshots of the feature. Be aware, that the feature has not been released, so the screenshots are subject to change.

BizTalk Server Send Port

Restart BizTalk Server Send Port

So, if you have BizTalk360, you won’t need to create PowerShell and the Windows Task Scheduler to start/stop/restart those components. All you have to do is to wait for v10.3 to be released.