PowerShell,BizTalk和更改主机实例配置 [英] PowerShell, BizTalk and changing Host Instance configuration

查看:36
本文介绍了PowerShell,BizTalk和更改主机实例配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还有另一个PowerShell/BizTalk问题,但首先要了解一些背景知识:

Yet another PowerShell/BizTalk question, but first some background:

在一个开发人员环境中,我们有很多(8个进程内,2个隔离)主机实例.其中一个实例已损坏(管理控制台中的状态为安装失败").我看到它缺少密码,并尝试手动更新它.运气不好,我输入的密码有误,也与该帐户在我们的CMDB中存储的密码相同...哦,很好.只是要重置它并在所有主机实例上对其进行更改.

We have a lot of (8 inprocess, 2 isolated) Host Instances on one developer environment. One of the instances has gone corrupt ("Installation Failed" as status in Admin Console). I saw that it was lacking password and tried to update it manually. No luck, the password I had was wrong and it was also the same password stored for the account in our CMDB... Oh, well. Just to reset it and change it on all host instances.

好吧,我想尝试以PowerShell方式进行操作.这是可行的,但是仅当实例在ServiceState 8中时才有效吗? ServiceState 4(已启动)当然会给出错误.但是ServiceState 1(已停止)是否也如此?

Well, I wanted to try out to do it the PowerShell way. It kind of works, but only if the instances is in ServiceState 8? ServiceState 4 (started) of course gives an error. But so does ServiceState 1 (stopped)?

非常烦人.是安装失败的方法:

Very annoying. It is the method Install that fails:

异常调用安装":安装Windows NT时发生故障 服务BTSSvc $ Test_host. 请验证以下内容: 1)提供的凭据正确,并且指定的用户名带有"log 启用作为服务启用". 2)所有Microsoft管理控制台(MMC)服务窗口均已关闭.窗户 如果服务的服务控制管理器不允许创建服务,则该服务将不允许创建服务. 已被删除,但仍由打开的MMC窗口引用. "

Exception calling "Install" : "A failure occurred while installing the Windows NT service BTSSvc$Test_host. Please verify the following: 1) The credentials supplied are correct and the specified user name has the "log on as service" privilege enabled. 2) All Microsoft Management Console (MMC) Service windows are closed. The Window s Service Control Manager will not allow the creation of a service if the service has been deleted but is still referenced by an open MMC window. "

代码:

$hosts = Get-WmiObject MSBTS_HostInstance -namespace 'root/MicrosoftBizTalkServer'
foreach($hostinst in $hosts)
{
    if ($hostinst.Logon -eq $acc)
    {
        if($hostinst.ServiceState -eq 1 -or 8)
        {
            write-host "Hostinstans" $hostinst.HostName "har ServiceState" $hostinst.ServiceState
            $hostinst.Install($acc, $pw, "True")
            Start-Sleep -Seconds 30
            write-host "Hostinstans" $hostinst.HostName "har nytt lösenord och ServiceState" $hostinst.ServiceState
        }
    }
}

有人知道吗?真烦人了!

Anyone got ideas? It is annoying the cr*p out of me!

最诚挚的问候,

Joakim

推荐答案

找到了答案!

如果该实例处于ServiceState 1,则必须对其进行任何更改之前先将其卸载!我的代码应该是这样的(例如):

If the instance is in ServiceState 1 I have to uninstall it before making any changes to it! My code for this should be like this (for example):

    $hosts = Get-WmiObject MSBTS_HostInstance -namespace 'root/MicrosoftBizTalkServer'
foreach($hostinst in $hosts)
{
    if ($hostinst.Logon -eq $acc)
    {
        if(($hostinst.ServiceState -eq 1) -or ($hostinst.ServiceState -eq 8))
        {
            if($hostinst.ServiceState -eq 1)
            {
               $hostinst.Uninstall()
            }
            write-host "Hostinstans" $hostinst.HostName "har ServiceState"     $hostinst.ServiceState
            $hostinst.Install($acc, $pw, "True")
            Start-Sleep -Seconds 30
            write-host "Hostinstans" $hostinst.HostName "har nytt lösenord och ServiceState" $hostinst.ServiceState
        }
    }
}

这篇关于PowerShell,BizTalk和更改主机实例配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆