We are using the following command to deploy BizTalk assemblies via PowerShell:
BTSTask AddResource /ApplicationName:$App /Type:$BizTalkAssemblyType /Overwrite /Source:$Source /Options:GacOnAdd,GacOnInstall,GacOnImport
See: https://learn.microsoft.com/en-us/biztalk/core/addresource-command-biztalk-assembly
There are certain reasons this command can fail, e.g. an orchestration is not in the unenlisted state or one or more instances of the orchestration exists.
In this case the command does not raise an error so the script continues with an output like
Command failed with 1 errors, 0 warnings.
Because in this situation the assembly does not get deployed we would like to fail the PowerShell script e.g. by raising an error. How to achieve this?
You need to capture the output and check it for the failure, or rather, check for success and fail if it doesn't.
[array] $cmdOutput = BTSTask AddResource /ApplicationName:$App /Type:$BizTalkAssemblyType /Overwrite /Source:$Source /Options:"GacOnAdd,GacOnInstall,GacOnImport"
$line = $cmdOutput.Count-2
if ( $cmdOutput[$line] -eq "Command succeeded with 0 errors, 0 warnings.")
{
Write-Output "Deploy suceeded"
}
else
{
Throw "Deploy failed $cmdOutput"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With