2017-08-16 34 views
0

我有下面的PowerShell腳本找出所有不同的BizTalk狀態:查找運行服務實例的BizTalk應用程序的不同狀態

  • 實例運行準備
  • 活動實例
  • 脫水實例
  • 斷點處的實例
  • 掛起的編排
  • 掛起的消息
  • 路由故障
  • 隔離適配器故障

PowerShell腳本

# 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 

是否有任何WMI對象來連接運行實例的BizTalk應用程序相關的活動?

Application name = Microsoft.Practices.ESB一樣,有多少個活動的運行實例?如果它不止20次向我發送電子郵件通知。

請告訴我如何使用PowerShell實現功能,我也看到MSBTS_ServiceInstance wmiobject不提供BizTalk應用程序屬性。

參考 - BizTalk Server Health Check PowerShell Script

回答

-1

這個腳本會給你結果所有您的應用Active,ReadytoRun和Dehydrated服務實例狀態:

# 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 

} 

} 
+0

你問了一個問題,然後有人給你指出了正確的方向。與其接受他/她的回答,你創造了自己的答案,然後接受了答案。對不起,但我會做我能做的事:投票你的答案,並投票正確的。 – Zee

+0

呦!首先,在我放置劇本之前,先標記他的答案。後來他或某人刪除了這個答案,所以我標記了我自己的答案,指出其他問題已經解決。無論如何,我不會爲任何積分或任何狀態而戰。祝你好運!謝謝 –

+0

@Zee也看看兩個腳本之間有什麼不同,感覺不同。 –

2

我覺得這是你所需要的Get Biztalk serviceInstance details with Powershell

訣竅是集名稱過濾器通配符:

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 
+0

非常感謝您,我還會通過每個服務實例@felixmondelo更新所有BizTalk應用程序循環的最新腳本! –

相關問題