How to Restart the SFTP BizTalk Server Host Instance with PowerShell

  • Sandro Pereira
  • Jul 7, 2025
  • 4 min read

There are some common challenges we face as BizTalk Server developers and administrators, and one of them is the occasional instability or unexpected behavior of the SFTP adapter.

Over time, we’ve seen that the SFTP adapter may stop functioning as expected, failing to poll, silently dropping messages, or even becoming unresponsive. This behavior is often caused, maybe, by issues like:

  • Memory leaks in the SFTP adapter or underlying WinSCP sessions.

One of the most common workarounds that typically resolves these problems is simply restarting the Host Instance responsible for handling the SFTP adapter.

📝 One-Minute Brief

In this blog post, we explore how to resolve common issues with the BizTalk SFTP adapter — such as connection failures or unexpected behavior — by restarting the host instance that runs it. You’ll learn why these problems often occur, how restarting the host instance can quickly restore functionality, and the two main ways to automate this process using PowerShell.

By the end, you’ll understand:

  • When and why the SFTP adapter may require a restart.
  • How to identify and restart the correct BizTalk host instance.
  • How to restart it using PowerShell Script.
  • Best practices for keeping your SFTP-based integrations stable and efficient.

A small action that can make a big difference in your BizTalk environment’s reliability.

Today’s blog post is a quick guide on how to restart a specific BizTalk Server Host Instance using PowerShell — specifically, the one used for SFTP operations.

PowerShell to the Rescue!

First, we need to identify the Host Instance that’s running the SFTP Receive Location or Send Port. In most environments, this is a dedicated BizTalk Host (e.g., BizTalkSFTPHost) to isolate adapter-related behavior — a good practice, by the way!

You can restart this Host Instance using PowerShell in different ways. Today, we will be describing one of those methods.

Restart Using WMI

WMI gives you direct access to BizTalk Host Instance metadata, including remote server targeting and filtering by host name. Here’s a sample script:

$hostName = "Your-sftp-BizTalk-Host-Instance-Name"     # Change this to your actual host name
$serverName = "Your-Server-Name"                                  # Change this to your BizTalk server name

# Get the BizTalk Host Instance
$hostInstance = Get-WmiObject -Namespace "root\MicrosoftBizTalkServer" -Class MSBTS_HostInstance |
    Where-Object { $_.HostName -eq $hostName -and $_.RunningServer -eq $serverName }

if ($hostInstance) {
    Write-Host "Stopping host instance..."
    $hostInstance.Stop()
    Start-Sleep -Seconds 5

    Write-Host "Starting host instance..."
    $hostInstance.Start()
    
    Write-Host "Host instance restarted successfully."
} else {
    Write-Host "Host instance not found."
}

Make sure to run PowerShell as Administrator and that your user has appropriate permissions to manage BizTalk WMI objects.

Why This Matters

The SFTP adapter is powerful, but like any component that relies on external libraries (in this case, the WinSCP .NET assembly), it can run into unmanaged memory issues over time. A periodic or reactive host instance restart is often the quickest and cleanest solution to restore full functionality.

Perhaps this is not the most elegant solution, but restarting the SFTP BizTalk Host Instance is a simple yet effective way to restore stability to your integrations when the adapter starts behaving erratically. Automating it via PowerShell enables you to integrate it into maintenance jobs or monitoring alerts, giving your BizTalk environment a self-healing touch.

Stay safe, script smart, and until the next post — happy integrations!

Download

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

You can download the PowerShell Script used from GitHub here:

Hope you find this helpful! If you enjoyed the content or found it useful and wish to support our efforts to create more, you can contribute towards purchasing a Star Wars Lego for my son!

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top