문제

I have this pre-deploy powershell script running:

sc.exe stop "someservice" -ErrorAction SilentlyContinue

I'm expecting that the someservice will be stopped if it exist, and if it doesn't, the error will get swallowed.

However, when I push a new service out, I get an error saying the service isn't found.

Inb4 - The service needs to be installed in a special way (a third party service), so i can't use octopus deploy's service installer.

도움이 되었습니까?

해결책

The reason why you are not getting the desired result is because sc.exe is not a powershell cmdlet, it is a windows server program. Instead, use the stop-service cmdlet

Stop-Service -Name ServiceName -Force -ErrorAction SilentlyContinue

get-help stop-service -online

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top