1

I have the below PowerShell script to find out all different BizTalk states :

  • Instances Ready to Run
  • Active Instances
  • Dehydrated Instances
  • Instances in Breakpoint
  • Suspended Orchestrations
  • Suspended Messages
  • Routing Failures
  • Isolated Adapter Failures

PowerShell Script

# SQL Settings

$BTSSQLInstance = get-wmiobject MSBTS_GroupSetting -namespace root\MicrosoftBizTalkServer | select-object -expand MgmtDbServerName
$BizTalkManagementDb = get-wmiobject MSBTS_GroupSetting -namespace root\MicrosoftBizTalkServer | select-object -expand MgmtDbName

# Connect the BizTalk Management database

[void] [System.reflection.Assembly]::LoadWithPartialName("Microsoft.BizTalk.ExplorerOM")
$BTSCatalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
$BTSCatalog.ConnectionString = "SERVER=$BTSSQLInstance;DATABASE=$BizTalkManagementDb;Integrated Security=SSPI"

# Get BizTalk Service Instance Information
[ARRAY]$readyToRun = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 1)' -ErrorAction SilentlyContinue
[ARRAY]$active = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 2) and not(ServiceClass = 16)' -ErrorAction SilentlyContinue
[ARRAY]$dehydrated = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 8)' -ErrorAction SilentlyContinue
[ARRAY]$breakpoint = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 64)' -ErrorAction SilentlyContinue
[ARRAY]$suspendedOrchs = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceClass = 1) and (ServiceStatus = 4 or ServiceStatus = 32)' -ErrorAction SilentlyContinue
[ARRAY]$suspendedMessages = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceClass = 4) and (ServiceStatus = 4 or ServiceStatus = 32)' -ErrorAction SilentlyContinue
[ARRAY]$suspendedRouting = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceClass = 64)' -ErrorAction SilentlyContinue
[ARRAY]$suspendedIsolated = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceClass = 32) and (ServiceStatus = 4 or ServiceStatus = 32)' -ErrorAction SilentlyContinue

# Display BizTalk Service Instance Information

Write-Host "`nService Instance Information" -fore DarkGray
Write-Host "Instances Ready to Run:" $readyToRun.Count
Write-Host "Active Instances:" $active.Count
Write-Host "Dehydrated Instances:" $dehydrated.Count
Write-Host "Instances in Breakpoint:" $breakpoint.Count
Write-Host "Suspended Orchestrations:" $suspendedOrchs.count
Write-Host "Suspended Messages:" $suspendedMessages.count
Write-Host "Routing Failures:" $suspendedRouting.count
Write-Host "Isolated Adapter Failures:" $suspendedIsolated.count

Is there any WMI object to concatenate related activities running instances for BizTalk Application?

Like Application name = Microsoft.Practices.ESB and how many active running instances there are? If it's more that 20 send me email notification.

Please advise me how we can achieve that functionally using powershell also I have seen MSBTS_ServiceInstance wmiobject not providing BizTalk Application property.

Reference -- BizTalk Server Health Check PowerShell Script

Dijkgraaf
  • 9,324
  • 15
  • 34
  • 48
Dipen Patel
  • 230
  • 3
  • 15

2 Answers2

3

I think this is what you need Get Biztalk serviceInstance details with Powershell

The trick is filter by Assembly Name with wildcards as:

Get-WmiObject -Class "MSBTS_ServiceInstance" -Namespace  'root\MicrosoftBizTalkServer' | Where-Object {  $_.ServiceClass -eq "1" -and ($_.ServiceStatus -eq "4" -or $_.ServiceStatus -eq "32") -and $_.AssemblyName -like "*BizTalkMassCopy*" } | measure
felixmondelo
  • 1,224
  • 1
  • 10
  • 16
  • Thanks you much and also I will update latest script for all BizTalk Application loop through each service instances @felixmondelo !! – Dipen Patel Aug 17 '17 at 15:02
-1

This script will give you results for All your application Active,ReadytoRun and Dehydrated service Instances status:

# SQL Settings     

 $BTSSQLInstance = get-wmiobject MSBTS_GroupSetting -namespace root\MicrosoftBizTalkServer | select-object -expand MgmtDbServerName
 $BizTalkManagementDb = get-wmiobject MSBTS_GroupSetting -namespace root\MicrosoftBizTalkServer | select-object -expand MgmtDbName

# Connect the BizTalk Management database

[void] [System.reflection.Assembly]::LoadWithPartialName("Microsoft.BizTalk.ExplorerOM")
$BTSCatalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
$BTSCatalog.ConnectionString = "SERVER=$BTSSQLInstance;DATABASE=$BizTalkManagementDb;Integrated Security=SSPI"

# Get BizTalk Application Information

$applications = $BTSCatalog.Applications

# Display BizTalk Application Information

Write-Host "`nBizTalk Applications ("$applications.Count")" -fore DarkGray

Foreach ($application in $applications) {

if ($application.Status -eq "Started") {


[ARRAY]$readyToRun = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 1)' -ErrorAction SilentlyContinue | Where-Object { $_.AssemblyName -like $application.Name }
[ARRAY]$active = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 2) and not(ServiceClass = 16)' -ErrorAction SilentlyContinue | Where-Object { $_.AssemblyName -like $application.Name }
[ARRAY]$dehydrated = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter '(ServiceStatus = 8)' -ErrorAction SilentlyContinue | Where-Object { $_.AssemblyName -like $application.Name }

Write-Host "`nService Instance Information for" $application.Name -fore DarkGray
Write-Host "Instances Ready to Run:" $readyToRun.Count
Write-Host "Active Instances:" $active.Count
Write-Host "Dehydrated Instances:" $dehydrated.Count

}

}
Dipen Patel
  • 230
  • 3
  • 15
  • You asked a question then someone pointed you the right direction. Instead of accept his/her answer, you created your own answer then accepted it. Sorry but I'll do what I can do: down vote your answer and up vote the right one. – Zee Aug 21 '17 at 06:24
  • Yo!!! First I mark his answer before I place my script. later he or someone removed that as an answer so I mark my own answer to point out other that questions has been solved. Anyway I'm not fighting anything for points or any status..good luck to your decision..Thanks – Dipen Patel Aug 21 '17 at 06:29
  • @Zee also take look what's different between both script and feel different. – Dipen Patel Aug 21 '17 at 06:39