Ask Your Question

Onlyif not functioning even when return is not "0"

asked 2016-09-09 11:35:39 -0600

JDFlanigan gravatar image

I have an exec which executes a powershell command to stop and delete a service. It's dependent on an onlyif which is using powershell's "Get-Service" to check if the service exists. I can see that the Get-Service call is returning 1060 (service doesn't exist), but the command still attempts to execute.

Am I missing something here?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-09-09 15:27:01 -0600

JDFlanigan gravatar image

Turns out PowerShell doesn't give an exit code in this scenario. It was necessary to add an if statement that would perform the check and call "exit 1" under any circumstances where I wouldn't want the command to execute.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-09-09 11:35:39 -0600

Seen: 32 times

Last updated: Sep 09 '16