powershellbiztalkbiztalk-2010biztalk-2013biztalk-2009

PowerShell script to detect Active instances of BizTalk send port


I have a PowerShell script to detect active instances of send port running in BizTalk. I am struggling with syntax to query the MSBTS_ServiceInstance to find the active instances of this send port.

Can anyone help me as to how to subsitute the name of the send port in the where clause or the filter clause please ?

[ARRAY]$active = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 2) and how to search by name' -ErrorAction SilentlyContinue 

 Write-Host "Active Instances:" $active.Count

Solution

  • This should do the trick

    [ARRAY]$active = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter {ServiceStatus = 2 and ServiceName = "port name"}  -ErrorAction SilentlyContinue 
    
    Please see Class definition and PowerShell syntax

    However I personaly prefer using Microsoft.BizTalk.Operations.dll with PowerShell to perform this kind of queries.