How to start and stop a BizTalk Server Application with PowerShell/BizTalk360

Long time since I played with PowerShell and BizTalk Server, but today I had a request from one of my clients who want to restart to SAP receive locations on a scheduled base. So, while helping them, I decided to publicly publish a series of resources related to this:

  • How to restart a BizTalk Server Receive Location with PowerShell/BizTalk360 – will be soon published on the BizTalk360 blog
  • How to restart a BizTalk Server Send Port with PowerShell/BizTalk360 – will be soon published on the BizTalk360 blog
  • How to restart a BizTalk Server Send Group with PowerShell/BizTalk360 – will be soon published on my blog
  • and this one of course.

There may be several reasons we want to stop and start BizTalk Server applications. One of the reasons is for planned external or internal systems interventions. For example, we know that our external system is down for maintenance on the first day or the last day of each month. There are several ways to do this, Stopping only the send ports or the receive location or entirely stopping the application.

You can do this by using BizTalk360, and many customers are actively using it, but that doesn’t mean that you cannot use this PowerShell script. Actually, BizTalk360 allows you to extend its out-of-the-box capabilities by allowing you to integrate PowerShell scripts with BizTalk360.

Of course, to use this script on a scheduled basis, you need to use it inside BizTalk360, or you can create a Task Scheduler on the BizTalk Server machine or any other machine with access to BizTalk Server.

PowerShell to Stop and Start a BizTalk Server Application

With this script, we can accomplish exactly that: Stop or/and Start a BizTalk Application by using PowerShell.

The function below accepts the BizTalk Application name and guarantees that a full stop is made. 

function stop-bts-application (
    [string]$appName,
    [Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer]$btsCataloglog) 
{
    # Get the BizTalk Application
    $application = $Catalog.Applications[$appName]

    # Going to check if the application status is stopped or not
    if ($application.Status -ne "Stopped")
    {
         # Force a full stop to the application
         $application.Stop("StopAll")
         $btsCataloglog.SaveChanges()
    }
}

The function below accepts the BizTalk Application name and guarantees that a full start is made. 

function start-bts-application (
    [string]$appName,
    [Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer]$btsCataloglog) 
{
    # Get the BizTalk Application
    $application = $Catalog.Applications[$appName]

    # Going to check if the application status is stopped or not
    if ($application.Status -ne "Started")
    {
         # Force a full stop to the application
         $application.Start("StartAll")
         $btsCataloglog.SaveChanges()
    }
}

THESE POWERSHELL SCRIPTS ARE PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.

Download

You can download PowerShell to Stop and Start a BizTalk Server Application from GitHub here:

Use BizTalk360 to Start and Stop a BizTalk Application

At the time of writing, the BizTalk360 team is working on v10.3. An important feature of that release will be the Automated Task feature. This will allow you to stop/start/restart ports, orchestrations, host instances, and logic apps on a scheduled basis.

See below, a couple of screenshots of the feature. Be aware, that the feature has not been released, so the screenshots are subject to change.

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published.

BizTalk360
BizTalk Server

Over 650+ customers across
30+ countries depend on BizTalk360

Learn More
Serverless360
Azure

Operate efficiently with enterprise-grade Azure monitoring,
tracing, remediation & governance in one platform

Learn More

Back to Top