使用Powershell远程启动服务

时间:2013-10-30 10:40:11

标签: c# teamcity powershell-v2.0

我有一个Powershell脚本,可以在远程计算机上启动服务。

它的确是这样的:

Invoke-Command -ComputerName $serverName -ScriptBlock { param($serviceexe) & $serviceexe -install }-ArgumentList $localExePath 

它可以在本地计算机上运行,​​也可以在Teamcity中作为构建步骤运行。

但是当我尝试从其他工具启动服务时,我收到了消息:

"cannot start service from the command line or a debugger".

这个其他工具是用C#编写的,使用System.Management.Automation.

我也尝试使用Process类,但仍然是同样的问题。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您是否考虑过Powershell Remote Requirements