Reputation: 57
I am using the below script to get the host instances state from a remote server in the same domain.
$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
}
I am getting this exception. But BizTalk is configured in the server and host instances are in running status.
Get-WmiObject : The server has not been configured. To configure the server, run the BizTalk Server Configuration wizard and configure the Group feature. At line:10 char:3 + Get-WmiObject -Class "MSBTS_HostInstance" -Namespace 'root\MicrosoftBizTalkSer ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
Anyone knows what the issue is? Or if you have a better version of the script, that ll be helpful too or any Cross domain scripts .
Note: my local machine is on PSv3 and remote BizTalk server is on v2.
Upvotes: 0
Views: 2081
Reputation: 673
I would use the BizTalk PowerShell Provider for this task. The BizTalk 2010 version (1.2.0.4) works with PowerShell 2. If you are in the possibility of using it, you can simply use the following commands to get the status of your host instances:
cd BizTalk:
Set-Location '..\Platform Settings\Host Instances'
Get-ChildItem
Sample output:
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
Upvotes: 0