Reputation: 320
I have the below PowerShell script to find out all different BizTalk states :
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
Upvotes: 1
Views: 2801
Reputation: 320
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
}
}
Upvotes: -1
Reputation: 1474
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
Upvotes: 3