Running a PS script to restart a Windows service results in FAILED job

82 views
Skip to first unread message

Simone Bianchelli

unread,
May 7, 2024, 11:58:17 AM5/7/24
to rundeck-discuss
Hi, im trying to restart a Windows service in a remote machine, i used the following PS script:

Restart-Service -Name "NETA Schedulatore Amministratore Service"

But the job always fails with this output:

[ERROR  ]  Execution finished with the following error (winrm-exec.py:378)[root]
[ERROR  ]  Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start...Waiting for service 'NETA Schedulatore Amministratore Service (NETA Schedulatore Amministratore Service)' to start... (winrm-exec.py:379)[root]
Failed: NonZeroResultCode: [WinRMPython] Result code: 1
Execution failed: 50 in project winupdates: [Workflow result: , step failures: {1=Dispatch failed on 1 nodes: [ITALGASSVI-AS: NonZeroResultCode: [WinRMPython] Result code: 1 + {dataContext=MultiDataContextImpl(map={ContextView(step:1, node:ITALGASSVI-AS)=BaseDataContext{{exec={exitCode=0}}}, ContextView(node:ITALGASSVI-AS)=BaseDataContext{{exec={exitCode=0}}}}, base=null)} ]}, Node failures: {ITALGASSVI-AS=[NonZeroResultCode: [WinRMPython] Result code: 1 + {dataContext=MultiDataContextImpl(map={ContextView(step:1, node:ITALGASSVI-AS)=BaseDataContext{{exec={exitCode=0}}}, ContextView(node:ITALGASSVI-AS)=BaseDataContext{{exec={exitCode=0}}}}, base=null)} ]}, status: failed]


If i check on the target node the service is effectively stopped then started (checked on the Event Viewer) but i don't know why the job fails.

I used the same script with other services and the run is OK, seems only with this service (i must say that this service takes a while to stop and restart).

rac...@rundeck.com

unread,
May 7, 2024, 12:12:18 PM5/7/24
to rundeck-discuss
Hi Simone,

Do you see any clue checking the output in debug mode?

Greetings.

rac...@rundeck.com

unread,
May 7, 2024, 12:20:53 PM5/7/24
to rundeck-discuss
Regarding this:

I used the same script with other services and the run is OK, seems only with this service (i must say that this service takes a while to stop and restart).

You can set a timeout in your job and test. To do so, edit your job, click the "Others" tab, and set a time in the "Timeout" field.

Hope it helps.

Simone Bianchelli

unread,
May 7, 2024, 12:29:03 PM5/7/24
to rundeck-discuss
Thanks but still getting failed after about 38 secs (i put a timeout of 180 secs).

Ran the job with debug but i don't see anything that can be useful to find the cause, here is the full log https://pastebin.ai/f8quy6xzfn

rac...@rundeck.com

unread,
May 7, 2024, 1:46:14 PM5/7/24
to rundeck-discuss
Could you try this way? The example needs a valid node name and a service name. So, edit the job according to your environment.

Regards.

Simone Bianchelli

unread,
May 8, 2024, 9:05:59 AM5/8/24
to rundeck-discuss
With that job it works, i managed to made it working also on my current project, i copied and adapted the entire script plus also filled the field invocation string: powershell.exe.

Thanks!

P.S: i checked the other runbooks in the welcome project, don't you have one for performing Windows updates using PSWindowsUpdate module right?

Reply all
Reply to author
Forward
0 new messages