Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BizTalk 2016 CU5 - WinSCP v5.13.1 Powershell installation script (courtesy of Thomas Canter, edited by me)
Param([Parameter(Mandatory=$true)][string]$downloadNoGetTo)
$Continue = $true
$downloadNoGetToExists = Test-Path $downloadNoGetTo
if (-not $downloadNoGetToExists)
{
New-Item -Path $downloadNoGetTo -ItemType "Directory"
}
if (-not $downloadNoGetToExists)
{
$Continue = $false
Write-Host "An attempt to use the " $downloadNoGetTo " directory for a download target failed"
}
if ($Continue)
{
$bizTalkInstallFolder = (Get-Item Env:BTSINSTALLPATH).Value
if (-not $bizTalkInstallFolder)
{
$bizTalkInstallFolder = (get-itemPropertyValue 'HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0' -Name 'InstallPath')
if (-not $bizTalkInstallFolder)
{
$bizTalkInstallFolder = "C:\Program Files (x86)\Microsoft BizTalk Server 2016\\"
}
}
$bizTalkInstallFolderExists = Test-Path $bizTalkInstallFolder
if (-not $bizTalkInstallFolderExists)
{
$Continue = $false
Write-Host "The BizTalk Installation was not found by inspecting the enviornment or registry."
}
if ($Continue)
{
#Download NuGet
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
Write-Host Downloading Nuget from $sourceNugetExe
$targetNugetExe = "$downloadNoGetTo\nuget.exe"
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
$targetNugetExeExists = Test-Path $targetNugetExe
if (-not $targetNugetExeExists)
{
$Continue = $false
Write-Host "The download of the Nuget EXE from " $sourceNugetExe " did not succeed"
}
if ($Continue)
{
#Download the right version of WinSCP
Write-Host "Downloading WinSCP from NuGet " + $sourceNugetExe
Invoke-Expression "$targetNugetExe Install WinSCP -Version 5.13.1 -OutputDirectory $downloadNoGetTo"
$WinSCP = "$downloadNoGetTo\WinSCP.5.13.1\tools\WinSCP.exe"
$WinSCPDll = "$downloadNoGetTo\WinSCP.5.13.1\lib\net\WinSCPnet.dll"
$WinSCPExists = Test-Path $WinSCP
$WinSCPDLLExists = Test-Path $WinSCPDll
if (-not $WinSCPExists -or -not $WinSCPDLLExists)
{
$Continue = $false
Write-Host "WinSCP 5.13.1 was not properly downloaded"
}
if ($Continue)
{
#Copy WinSCP items to BizTalk Folder
Write-Host "Copying WinSCP Nuget to BizTalk Folder"
Copy-Item $WinSCP $bizTalkInstallFolder
Copy-Item $WinSCPDll $bizTalkInstallFolder
$WinSCPBTSExists = Test-Path "$bizTalkInstallFolder\WinSCP.exe"
$WinSCPDLLBTSExists = Test-Path "$biztalkInstallFolder\WinSCPnet.dll"
if (-not $WinSCPBTSExists)
{
$Continue = $false
Write-Host "The WinSCP.exe file was not properly copied to the target folder " $bizTalkInstallFolder
}
if (-not $WinSCPDLLBTSExists)
{
$Continue = $false
Write-Host "The WinSCPnet.exe file was not properly copied to the target folder " $bizTalkInstallFolder
}
}
}
}
}
if (-not $Continue)
{
Write-Host "Something went wrong during installation and the installation is not working"
Write-Host "Please inspect the errors above and resolve them"
}
else
{
Write-Host "WinSCP has been properly installed for BizTalk's SFTP Adapter"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment