Ask Your Question

Detecting if windows service is already installed using puppet exec

asked 2016-06-08 07:49:55 -0600

praneethjonna gravatar image

I have below exec resource which is used to install a window service. I want to it to execute only if the window service is not installed.So I have onlyif command but the command is not working it is running the install all the time. Any help regarding this appreciated.

exec { "install-${target_path}/${binary_name}":
    command   => "${installUtil_filepath} /i /servicename=\"${service_name}\" /displayname=\"${display_name}\" /description=\"${description}\" \"${target_path}\\${binary_name}\"",
    onlyif    => "if((Get-Service \"${service_name}\" -ErrorAction SilentContinue).DisplayName -eq  ${display_name}) { exit 1 } else { exit 0 }",
    logoutput => true,
    provider => powershell,
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-06-08 11:00:06 -0600

praneethjonna gravatar image

if(Get-Service \"${service_name}\") { exit 1 } else { exit 0 }. This works

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-06-08 07:49:55 -0600

Seen: 627 times

Last updated: Jun 08 '16