无法使用Powershell获取Biztalk主机实例状态

时间:2014-08-13 14:46:06

标签: powershell biztalk powershell-v3.0 biztalk-2010

我使用以下脚本从同一域中的远程服务器获取主机实例状态。

    $servers = ("usxxxxxxx01")

 function checkhostinstancestatusstarted ($server)
 {

$hostinstances = get-wmiobject MSBTS_HostInstance -namespace 'root\MicrosoftBizTalkServer'  | where {$_.runningserver -match $server -AND $_.hosttype -ne "2" -and $_.IsDisabled -ne    "True"}

write-host "Checking the state of all host instances on the server $server"

foreach ($hostinstance in $hostinstances)
    {
    $HostInstanceName = $HostInstance.hostname

    #Checks the host instance state
    if ($HostInstance.ServiceState -eq 1)
        {
        write-host "$HostInstanceName`: Stopped."
        }
    elseif ($HostInstance.ServiceState -eq 2)
        {
        write-host "$HostInstanceName`: Start pending."
        }
    elseif ($HostInstance.ServiceState -eq 3)
        {
        write-host "$HostInstanceName`: Stop pending."
        }
    elseif ($HostInstance.ServiceState -eq 4)
        {
        write-host "$HostInstanceName`: Started."
        }
    elseif ($HostInstance.ServiceState -eq 5)
        {
        write-host "$HostInstanceName`: Continue pending."
        }
    elseif ($HostInstance.ServiceState -eq 6)
        {
        write-host "$HostInstanceName`: Pause pending."
        }
    elseif ($HostInstance.ServiceState -eq 7)
        {
        write-host "$HostInstanceName`: Paused."
        }
    elseif ($HostInstance.ServiceState -eq 8)
        {
        write-host "$HostInstanceName`: Unknown."
        }
    }
write-host `n    
}

foreach ($server in $servers)
{
checkhostinstancestatusstarted $server 
}

我得到了这个例外。但是BizTalk在服务器中配置,主机实例处于运行状态。

  

Get-WmiObject:尚未配置服务器。要配置服务器,请运行BizTalk Server配置向导并配置组功能。在行:10 char:3 + Get-WmiObject -Class" MSBTS_HostInstance" -Namespace' root \ MicrosoftBizTalkSer ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidOperation :(:) [Get-WmiObject],COMException + FullyQualifiedErrorId:GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

任何人都知道问题是什么?或者,如果您有更好的脚本版本,那么它也会有所帮助,或者任何跨域脚本。

注意:我的本地计算机在PSv3上,而远程BizTalk服务器在v2上。

1 个答案:

答案 0 :(得分:0)

我会使用BizTalk PowerShell Provider执行此任务。 BizTalk 2010版本(1.2.0.4)适用于PowerShell 2.如果您可以使用它,只需使用以下命令获取主机实例的状态:

cd BizTalk:
Set-Location '..\Platform Settings\Host Instances'
Get-ChildItem

示例输出:

Path: BizTalk:\Platform Settings\Host Instances

Name                Host Name           Windows Group       Running Server      Host Type           Service State
----                ---------           -------------       --------------      ---------           -------------
Microsoft BizTal... BizTalkServerApp... LABO\BizTalk App... JM-BT1              InProcess           Running
Microsoft BizTal... BizTalkServerIso... LABO\BizTalk Iso... JM-BT1              Isolated            NotApplicable
Microsoft BizTal... ReceiveHost         LABO\BizTalk App... JM-BT1              InProcess           Running
Microsoft BizTal... SendHost            LABO\BizTalk App... JM-BT1              InProcess           Running
Microsoft BizTal... ProcessHost         LABO\BizTalk App... JM-BT1              InProcess           StopPending
Microsoft BizTal... TrackingHost        LABO\BizTalk App... JM-BT1              InProcess           Running