PowerShell script to detect Active instances of BizTalk send port

393 Views Asked by At

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
1

There are 1 best solutions below

0
Gediminas K Didžioji On BEST ANSWER

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.