Last blog post – How to Restart the SFTP BizTalk Server Host Instance with PowerShell – I had explained how you can restart the SFTP Host Instance with a simple PowerShell script using WMI. The main problem with that approach – well, maybe it’s not a problem, but personally I don’t like it – is that it requires two instructions: Start and Stop, with a delay in the middle, just to guarantee that the services have time to actually stop. However, this can be a point of failure, as the host instance may sometimes take a longer time to stop. So, I decided to publish a simple approach to addressing this task, one that I believe is more effective.
📝 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.
Once again, we face common challenges as BizTalk Server developers and administrators, one of which 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.
Today’s blog post provides a quick guide on how to restart a specific BizTalk Server Host Instance using a different and more powerful PowerShell script.
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 via Windows Service Name
Each BizTalk Host Instance is actually a Windows service named using this convention:
BTSSvc$<HostName>
So, if your SFTP Host Instance is called BizTalkSFTPHost, the Windows service is:
BTSSvc$BizTalkSFTPHost
To restart it, you can use the following script:
$hostName = "Your-sftp-BizTalk-Host-Instance-Name" # Change this to your actual host name
$serviceName = "BTSSvc$"+ $hostName
Restart-Service -Name $serviceName
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!