Today, I was helping a BizTalk Server customer migrate their process from using the FTP adapter to the SFTP adapter. And if you are familiar with the BizTalk SFTP adapter, you will be aware of the painful process of choosing the correct version of WinSCP and how that hell we need to do to work correctly with the BizTalk Server, which is quite simple in general:
- Download WinSCP and the .NET Library, ensuring you get the correct version!
- Copy the .exe and .dll to the BizTalk installation folder.
- DO NOT gac anything. If you GAC the .NET library, it will not work because it expects WinSCP.exe to be in the same path, so that’s why they both go into the BizTalk installation folder.
📝 One-Minute Brief
Automating tool installation helps keep environments consistent. This article shows how to use a PowerShell script to download a specific version of WinSCP, avoiding breaking changes and ensuring repeatable deployments across machines and pipelines.
However, the biggest issue is: what is the correct WinSCP version I need for my version of BizTalk Server 2016 or 2020?
And for that reason, Thomas E. Canter, on his day as a Phidiax consultant, decided to create this fantastic PowerShell script, BizTalk WinSCP Installer, which, during the years, has evolved and been improved by several people like Michael Stephenson, Nicolas Blatter, Niclas Öberg, and me.
If your environment has internet access, I recommend using that script to install WinSCP.
In my case, the production server had no internet access. To make things more complex, it also ran a different build version.
For example, the test environment used BizTalk Server 2016 with Feature Pack 3 and Cumulative Update 9. Production, however, ran Feature Pack 3 with Cumulative Update 5. Because of this mismatch, we could not copy files from other environments. We had to use a different WinSCP version.
To solve this scenario, I created a simple PowerShell script. It allows you to choose the WinSCP version to download. You can run it on any machine with internet access. The script does not depend on the build version of your environment.
This is a simple abstract of the PowerShell script:
$checkExeExists = Test-Path $targetNugetExe
if(-not $checkExeExists)
{
if ($PSCmdlet.ShouldProcess("$sourceNugetExe -OutFile $targetNugetExe", "Run Invoke-WebRequest ")) {
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
$targetNugetExeExists = Test-Path $targetNugetExe
if (-not $targetNugetExeExists) {
$Continue = $false
Write-Error "`n$bangString";
Write-Error "The download of the Nuget EXE from";
Write-Error $sourceNugetExe;
Write-Error "did not succeed";
Write-Error "$bangString";
}
else{
Write-Success "nuget.exe download successfully."
}
}
}
if ($PSCmdlet.ShouldProcess("$getWinSCP", "Run Command")) {
Invoke-Expression "& $getWinSCP";
$WinSCPEXEExists = Test-Path $WinSCPEXEDownload
$WinSCPDLLExists = Test-Path $WinSCPDllDownload
if (-not $WinSCPDLLExists) {
$Continue = $false
Write-Error "`n$bangString";
Write-Error "WinSCP $winSCPVersion was not properly downloaded.";
Write-Error "Check the folder and error messages above:";
Write-Error "$nugetDownloadFolder";
Write-Error "And determine what files did download or did not download.";
Write-Error "$bangString";
}
else{
Write-Success "WinSCP $winSCPVersion was properly downloaded."
}
}
THESE POWERSHELL SCRIPTS ARE PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
Where can I download it?
You can download the complete Azure Function source code here:
Hope you find this helpful! So, if you liked the content or found it helpful and want to help me write more content, you can buy (or help buy) my son a Star Wars Lego!