How to determine the process ID of BizTalk Host Instances with PowerShell

Posted: May 3, 2012  |  Categories: Administration BizTalk

In two of my previous posts I introduced and explained how to debug BizTalk components in Visual Studio: BizTalk – How to debug Custom Pipeline Components running on Isolated Host and Debugging External assembly’s or pipeline components – Attach to Process – which BizTalk process to use?.

In the last one, I presented two ways of how we could determine the process id of BizTalk Host Instances:

  • Using the Tasklist command. This command displays a list of applications and services with their Process ID (PID) for all tasks running on either a local or a remote computer.
  • Using C# code

Now I will present how we can accomplish this using PowerShell:

$machineName = hostname
$query = "root\MicrosoftBizTalkServer", "Select * from MSBTS_HostInstance where HostType = 1 and ServiceState = 4 and RunningServer = '$machineName'"
$hostInstanceSearch = new-object$query)

$hostInstanceList = $hostInstanceSearch.get()

foreach ($hostInstanceItem in $hostInstanceList)
   $processName = $hostInstanceItem.HostName
   $perfCounter = New-Object System.Diagnostics.PerformanceCounter("BizTalk:Messaging", "ID Process", $processName)
   $processID  = $perfCounter.NextValue()

   Write-Host "HostName: " -foregroundcolor yellow -NoNewLine
   Write-Host $hostInstanceItem.HostName -foregroundcolor white
   Write-Host "Process Id: " -foregroundcolor yellow -NoNewLine
   Write-Host $processID   -foregroundcolor white

You can download the script from:
Determining the process ID of BizTalk Host InstancesDetermining the process ID of BizTalk Host Instances
Microsoft | TechNet Gallery

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.

2 thoughts on “How to determine the process ID of BizTalk Host Instances with PowerShell”

  1. there is another way to figure out the PIDs for BizTalk host.

    If you have a 32 bit hosts then run the following:
    tasklist /SVC /fi “imagename eq btsntsvc.exe”

    and if you have 64 bit hosts then run this:
    tasklist /SVC /fi “imagename eq btsntsvc64.exe”

    the /fi is a filter and the eq is equals.

Leave a Reply

Your email address will not be published. Required fields are marked *

BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More

Manage and monitor serverless
components effortlessly

Learn More
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top