2014-04-17 34 views
0

我有这样的预部署PowerShell脚本运行:章鱼部署PowerShell的默默似乎继续不上班

sc.exe stop "someservice" -ErrorAction SilentlyContinue 

我期待,如果它存在的someservice将被停止,如果它不”吨,错误将被吞噬。

但是,当我推出新服务时,出现错误,提示服务未找到。

Inb4 - 服务需要以特殊方式安装(第三方服务),所以我不能使用章鱼部署的服务安装程序。

回答

2

你没有得到预期结果的原因是因为sc.exe不是powershell cmdlet,而是windows服务器程序。相反,使用stop-service cmdlet的

Stop-Service -Name ServiceName -Force -ErrorAction SilentlyContinue

get-help stop-service -online