none
Script to "Disable host instances from starting" RRS feed

  • Question

  • Hi

    I have seen the script(s) to start or stop host instances. But can anyone share script or link that disable/enable the host instance from starting.
    (I'm referring to, double click on host instance, check box "Disable host instance from starting"in "General" tab)

    Thanks
    Bhava

    Friday, March 18, 2016 4:59 PM

Answers

  • I'm big fan of tools like btstask.exe or BizTalk OM, so I'm looking for something like this, am I wrong?

    Keep in mind, the various BizTalk management API's are not in sync so there are some things that are only available through one package.  In this case, the IsDisabled property of a Host Instance is only available through WMI, meaning not btstask or ExplorerOM.

    This script will set IsDisabled on all BizTalk Host Instances in a Group:

    $hostInstances = Get-WmiObject MSBTS_HostInstance -namespace 'root/MicrosoftBizTalkServer'
    foreach($hostInstance in $hostInstances)
    {
        $hostInstance.IsDisabled = $true
        $hostInstance.Put()
    }
    

    If you will be doing more scripted management of BizTalk, please investigate the PowerShell Provider for BizTalk which is available at CodePlex: http://psbiztalk.codeplex.com/

    PSPB also supports setting Host Instance Properties through its API.

    • Marked as answer by Bhava Saturday, March 19, 2016 2:11 PM
    Saturday, March 19, 2016 1:39 PM
    Moderator

All replies

  • Hi Bhava,

    BizTalk host instance is a windows service. So you can make use powershell's Set-Service cmdlet to stop and disable it.

    PowerShell comes with an easy way to do so:

    Set-Service –Name theservice –Computer thecomputer –StartupType “selectedType”

    Where selectedType value can be:

    Automatic
    Manual
    Disabled

    Refer: How to change a service startup type with PowerShell

    Another way is described in one of the thread in stackoverflow.

    Refer: How to Disable all BizTalk Hostinstances with PowerShell script

    $hosts = Get-WmiObject MSBTS_HostInstance -Namespace 'root/MicrosoftBizTalkServer'
    
    
    foreach($hostinst in $hosts) {
        if ( ($hostinst.ServiceState -ne 8) ) { # ignore isolated hosts
    
            $svcName = ('BTSSvc${0}' -f $hostinst.HostName) # get something Get-Service can work with
    
            Get-Service -Name $svcName | Stop-Service -PassThru | Set-Service -StartupType disabled        
            Write-Host "Hostinstance" $hostinst.HostName "stopped and disabled"
        }
    }


    Rachit Sikroria (Microsoft Azure MVP)


    Friday, March 18, 2016 5:49 PM
    Moderator
  • I'm not a big fan of using generic windows service based solution to do this.
    I'm looking for something with BizTalk based solution.
    Thanks for your reply.

    Bhava

    Friday, March 18, 2016 7:56 PM
  • I'm not a big fan of using generic windows service based solution to do this.
    I'm looking for something with BizTalk based solution.
    Thanks for your reply.

    Bhava

    Hi Bhava,

    Thank you for posting on MSDN forum.

    Why you don't want to use Windows PowerShell Script to achieve your scenario. That is the best way for this type of activities and all BizTalk Admin can preferred the way that Rachit describe. May I know is there any specific reason to not use WPS script?

    In meanwhile, there are one table in BizTalkMgmtDb database, adm_HostInstance. In that table column name is DisableHostInstance

    select * from [BizTalkMgmtDb].dbo.[adm_HostInstance]

    If there value is 0 that means your check box 'Disable host instance from starting' is unchecked.

    If there value is -1 that means your check box 'Disable host instance from starting' is checked. 


    Thanks,

    If my reply is helpful please mark as Answer or vote as Helpful.

    My blog | Twitter | LinkedIn

    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

    Friday, March 18, 2016 8:19 PM
    Moderator
  • I'm big fan of tools like btstask.exe or BizTalk OM, so I'm looking for something like this, am I wrong?

    Bhava.

    Friday, March 18, 2016 8:37 PM
  • I'm big fan of tools like btstask.exe or BizTalk OM, so I'm looking for something like this, am I wrong?

    Bhava.

    BTSTask.exe is really a very good tool for many purpose. BTSTask allows you to perform many application management tasks from the command line. BTSTask Command-Line Reference

    And many more activities can perform with BTSTask.exe, like, 

    1. Export an application .msi file
    2. Import an application .msi file
    3. Create or delete an application
    4. Uninstall an application(or use Add or Remove Programs Control Panel)
    5. Add artifacts to an application or remove artifacts from an application
    6. Import and export bindings and binding files
    7. Import and export policies

    Note: You cannot use BTSTask commands in a preprocessing or postprocessing script that will run during application import. If you do, the import may fail. This is because changes being made during import are not visible to scripts.

    Currently I haven't this type of script for BTSTask.exe but,

    My question is still same, Why you don't want to use PWS script, And one important question, Do you want this script to use frequently or any specific purpose?


    Thanks,

    If my reply is helpful please mark as Answer or vote as Helpful.

    My blog | Twitter | LinkedIn

    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

    Friday, March 18, 2016 9:02 PM
    Moderator
  • Hi Bhava,

    BizTalk host instance is a windows service. So you can make use powershell's Set-Service cmdlet to stop and disable it.

    PowerShell comes with an easy way to do so:

    Set-Service –Name theservice –Computer thecomputer –StartupType “selectedType”

    Where selectedType value can be:

    Automatic
    Manual
    Disabled

    Refer: How to change a service startup type with PowerShell

    Another way is described in one of the thread in stackoverflow.

    Refer: How to Disable all BizTalk Hostinstances with PowerShell script

    $hosts = Get-WmiObject MSBTS_HostInstance -Namespace 'root/MicrosoftBizTalkServer'
    
    
    foreach($hostinst in $hosts) {
        if ( ($hostinst.ServiceState -ne 8) ) { # ignore isolated hosts
    
            $svcName = ('BTSSvc${0}' -f $hostinst.HostName) # get something Get-Service can work with
    
            Get-Service -Name $svcName | Stop-Service -PassThru | Set-Service -StartupType disabled        
            Write-Host "Hostinstance" $hostinst.HostName "stopped and disabled"
        }
    }


    Rachit Sikroria (Microsoft Azure MVP)



    I'm not a big fan of using generic windows service based solution to do this.
    I'm looking for something with BizTalk based solution.
    Thanks for your reply.

    Bhava

    As mentioned before you have to use PowerShell and WMI to disable BizTalk Host instance. The Host instances are only windows services.

    For accessing host instances, its status and then for disabling it, ExplorerOM doesn’t give options(or ExplorerOM class’s members).

    People have always relied on WMI they have excellent root\\MicrosoftBizTalkServer to access the host instance and its details. I have provided you exactly this and this is the best available way to access the host instance details.

    Also when you have WMI option to achieve this, don’t access it through management database directly, use it the last option unless you don't have any way either using ExplorerOM/WMI. 

    Don’t use SQL query as suggest and don’t expose yourself prone for SQL injections.

    Also using WMI for host details is the document options from Microsoft. http://msdn.microsoft.com/en-us/library/aa561981.aspx



    Rachit Sikroria (Microsoft Azure MVP)


    Saturday, March 19, 2016 4:44 AM
    Moderator
  • I'm big fan of tools like btstask.exe or BizTalk OM, so I'm looking for something like this, am I wrong?

    Keep in mind, the various BizTalk management API's are not in sync so there are some things that are only available through one package.  In this case, the IsDisabled property of a Host Instance is only available through WMI, meaning not btstask or ExplorerOM.

    This script will set IsDisabled on all BizTalk Host Instances in a Group:

    $hostInstances = Get-WmiObject MSBTS_HostInstance -namespace 'root/MicrosoftBizTalkServer'
    foreach($hostInstance in $hostInstances)
    {
        $hostInstance.IsDisabled = $true
        $hostInstance.Put()
    }
    

    If you will be doing more scripted management of BizTalk, please investigate the PowerShell Provider for BizTalk which is available at CodePlex: http://psbiztalk.codeplex.com/

    PSPB also supports setting Host Instance Properties through its API.

    • Marked as answer by Bhava Saturday, March 19, 2016 2:11 PM
    Saturday, March 19, 2016 1:39 PM
    Moderator
  • An old post, but ...

    BizTalk host instance is a windows service. So you can make use powershell's Set-Service cmdlet to stop and disable it.

    PowerShell comes with an easy way to do so:

    Set-Service –Name theservice –Computer thecomputer –StartupType “selectedType”

    Where selectedType value can be:

    Automatic
    Manual
    Disabled

    Only problem you can't reset the service configuration to "delayed start" which is mandatory for biztalk service

    Use the MicrosoftBizTalkServer namespace and IsDisabled property or  the PowerShell Provider for BizTalk
    Please note: Using WMI can cause double hop issues as you go from Biztalk Server to SQL server 

    /Peter

    Sunday, August 13, 2017 9:29 AM