2012-10-12 33 views
3

您好我有一个PowerShell脚本来停止集群管理器的服务,卸载服务,重新安装服务,并从集群管理器启动服务。 NServiceBus.Host.exe用于卸载并重新安装该服务。我遇到了安装问题。即使我发送“/ startManually”作为参数,服务也会成功安装,但服务始终为自动启动类型。其次,在安装时,我得到了用户sql错误的登录失败,指出userName是本地计算机名称,即使我指定了要使用的服务的用户名和密码。以下是我的安装服务的代码行。任何帮助将是一个祝福。从Powershell运行NServiceBusHost.exe

& "NServiceBus.Host.exe" ("/install", "/startManually", "/serviceName:$ServiceName", "/displayName:$ServiceName", "/username:$ServiceUserName", "/password:$ServicePassword") > tmp.txt 
+0

我们正在调查/ startManually(将在此处报告)。关于与DB的连接:我们运行schemaupdates作为运行安装的用户,因为您指定的“service”用户可能没有权限在生产中更新/创建表。 –

+0

感谢您发布此信息,这将在NSErviceBus 3.4版中处理。在NServiceBus GitHub上有一个悬而未决的问题:[link](https://github.com/NServiceBus/NServiceBus/issues/700) – Shlomi

+0

所以我需要运行powershell脚本作为一个在机器上拥有权限的用户它正在安装以及它指向的数据库的权限? – Lizzard

回答

1

我通常建议使用Start-Process cmdlet从PowerShell启动进程。这使得启动过程的整个过程(无双关语)更容易排除故障。

您可以将命令行参数构建到变量中,并将结果变量传递给参数-ArgumentList

$Arguments = '/install /startManually /serviceName:{0} /displayName:{0} /username:{1} /password:{2}' -f $ServiceName, $ServiceUserName, $ServicePassword) 
$nServiceBus = Resolve-Path -Path nServiceBus.Host.exe; 

Write-Host -Object ('Argument string is: {0}' -f $Arguments); 
Write-Host -Object ('Path to nServiceBus.Host.exe is: {0}' -f $nServiceBus); 
Start-Process -Wait -NoNewWindow -FilePath $nServiceBus -ArgumentList $Arguments -RedirectStandardOutput tmp.txt; 

希望这会有所帮助。