Search code examples
powershellbiztalkbiztalk-2010

PowerShell to start only running Host Instances


We have an windows clustered environment with clustered FTP and MQ host instances and non clustered host instances.

I want to be able to restart the running host instances only. I have a script to start all host instances but we do not want to start the stopped ones on the passive cluster node. I have a script to start all host instances.

Anyone have any ideas how to only start running ones other than a script that reads from a list of specific host instances?


Solution

  • Continuing with the @jcarreiro solution, you have to get the Host Instances, filtering by HostType = 1 and ServiceState = 4.

    The values of Host Type are: 1 - In-process, 2 - Isolated

    The values of ServiceState are: 1 - Stopped, 2 - Start pending, 3 - Stop pending, 4 - Running, 5 - Continue pending, 6 - Pause pending, 7 - Paused, 8 - Unknown

    [ARRAY]$hostInstances = Get-WmiObject MSBTS_HostInstance -namespace "root\MicrosoftBizTalkServer" -Filter "(HostType = 1 and ServiceState = 4)" 
    Write-Host ("Total Number of Host Instances running : "+$hostInstances.Count) -Fore Yellow 
    Write-Host “Re-starting Host instance” -Fore Yellow 
    
    foreach ($hostInstance in $hostInstances) 
    { 
        $hostInstance.Stop()
        $hostInstance.Start()
    }
    
    Write-Host “Host instances are restarted successfully” -Fore Green