Check if BizTalk Application Exists (with Powershell Extensions)

I’m writing a custom deploy solution for BizTalk. If the application doesn’t exist, I need to call “BTSTask AddApp” to add it.

Sample:


Add-PSSnapIn -Name BiztalkFactory.PowerShell.Extensions

function checkApplicationExists ($appName) 
{
    cd "Biztalk:\Applications"
    $apps = Get-ChildItem
    $boolFoundMatch = $false 
    foreach ($app in $apps) 
      {
         Write-Host "  Testing $($app.Name) " 
         if ($app.Name -eq $appname) 
         {
            $boolFoundMatch = $true 
         }
      }
    return $boolFoundMatch 
  
}

cls
# Test an application that you know exists 
$appName = "Test.Vendors"
$app1Exists = checkApplicationExists $appname 
Write-Host "$appName $app1Exists" 

# Test an application that you know does not exist 
$appName = "Test.Vendors.NonExistent"
$app1Exists = checkApplicationExists $appname 
Write-Host "$appName $app1Exists" 

Uncategorized  

Leave a Reply