Yet another PowerShell/BizTalk question, but first some background:
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.
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:
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. "
Code:
$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!
Best regards,
Joakim