Wenn Sie BizTalk WMI/ExplorerOM nicht installiert haben oder nicht (denken Sie daran - Sie versuchen, die Microsoft.BizTalk.ExplorerOM DLL dort explizit zu laden), könnten Sie mit nur einem Invoke-Sqlcmd
- aber beachten Sie, dass dies fragiler ist als die Verwendung des OM, könnte mit neuen Versionen brechen, sollte mit äußerster Vorsicht in der Produktion verwendet werden, etc ... Es funktioniert möglicherweise auch nicht, wenn es dynamische Send-Ports im Spiel gibt (I don ' t haben derzeit keine zum Testen bereitgestellt.
$sql = "SELECT app.nvcName as Name,
CASE
WHEN SUM(o.nOrchestrationStatus) IS NULL AND SUM(r.Disabled) IS NULL AND SUM(sprt.nPortStatus) IS NULL THEN 'N/A'
WHEN SUM(CASE WHEN o.nOrchestrationStatus IS NULL THEN 3 ELSE o.nOrchestrationStatus END) = COUNT(*) * 3 AND SUM(CASE WHEN r.Disabled IS NULL THEN 0 ELSE r.Disabled END) = 0 AND sum(CASE WHEN sprt.nPortStatus IS NULL THEN 3 ELSE sprt.nPortStatus END) = count(sprt.nPortStatus) * 3 THEN 'Started'
WHEN SUM(CASE WHEN o.nOrchestrationStatus IS NULL THEN 1 ELSE o.nOrchestrationStatus END) = count(*) AND SUM(CASE WHEN r.Disabled IS NULL THEN -1 ELSE r.Disabled END) = -COUNT(*) AND sum(CASE WHEN sprt.nPortStatus IS NULL THEN 1 ELSE sprt.nPortStatus END) = count(*) THEN 'Stopped'
ELSE 'Partially Started'
END as Status
FROM bts_application app WITH(NOLOCK)
LEFT JOIN (
SELECT asm.nApplicationID, orch.nvcName, orch.nOrchestrationStatus FROM bts_assembly asm WITH(NOLOCK)
inner join bts_orchestration orch WITH(NOLOCK)
on asm.nid = orch.nAssemblyID) o
ON o.nApplicationID = app.nID
LEFT JOIN bts_sendport sprt with(nolock)
ON sprt.nApplicationID = app.nID
LEFT JOIN (
select rprt.nApplicationID, rprt.nvcName as rprtName, rloc.Name as rlocName, rloc.Disabled from bts_receiveport rprt with(nolock)
INNER JOIN adm_ReceiveLocation rloc with(nolock)
on rprt.nID = rloc.ReceivePortId) r
on r.nApplicationID = app.nid
--WHERE app.nvcName IN ('BT.Order.CustomerOrder','BT.Order.FControl')
GROUP BY app.nvcName"
Invoke-Sqlcmd -ServerInstance 'localhost' -Database 'BizTalkMgmtDb' -Query $sql | Where-Object { $_.Name -in 'BT.Order.CustomerOrder','BT.Order.FControl'}
Beachten Sie, dass Sie die Ergebnisse auf SQL-Ebene durch uncommenting die WHERE
-Klausel in der SQL-Zeichenfolge als auch begrenzen könnte.
Und beachten Sie, dass diese Abfrage kann erheblich vereinfacht werden, wenn Sie wirklich nur Anwendungen wollen und nicht über ihre Status - es wäre nur etwas wie Select nvcName from bts_application
.
Auf ServerA, haben Sie auch BizTalk installiert? –
Nein, ich habe BizTalk nicht in ServerA installiert. – medinibster