Remote script action fails on Windows server with error "Process completed on guest with error"

CloudBolt supports running scripts on remote servers, including Windows PowerShell scripts.

 

Symptoms:

During the process of running the remote script, the job fails with an error similar to:

Process 1048 completed on guest with error:
    (vim.vm.guest.ProcessManager.ProcessInfo) {
       dynamicType = <unset>,
       dynamicProperty = (vmodl.DynamicProperty) [],
       name = 'powershell.exe',
       pid = 1048L,
       owner = 'Administrator',
       cmdLine = '"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" C:\\Windows\\Temp\\03cc3978aafa493881a6c75ec1fef19c.ps1 10.50.22.230 > C:\\Windows\\Temp\\c2_stdout_tmp 2> C:\\Windows\\Temp\\c2_stderr_tmp',
       startTime = 2015-03-26T18:53:36Z,
       endTime = 2015-03-26T18:53:45Z,
       exitCode = 1
    }

 

Solutions:

There are a myriad of causes for this error. The best first step in troubleshooting is to get console on your Windows server and run the command exactly as seen in the error output where you see "cmdLine = ". In the above case that would mean opening a PowerShell prompt and running this (notice that the surrounding single quotes have been removed, but the double quotes stay):

"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" C:\\Windows\\Temp\\03cc3978aafa493881a6c75ec1fef19c.ps1 10.50.22.230 > C:\\Windows\\Temp\\c2_stdout_tmp 2> C:\\Windows\\Temp\\c2_stderr_tmp

 

One solution to consider is setting the Execution Policy in the Windows template to "Unrestricted". This can be done in PowerShell with `Set-ExecutionPolicy Unrestricted`.

Have more questions? Submit a request

1 Comments

  • 0
    Avatar
    Maryam Faiz

    In addition, if you are running the script as an orchestration action, add a few minutes delay before your script.

    The plug-in looks like this:

            import time
            from common.methods import set_progress

            def run(**kwargs):
                  seconds_to_sleep = "{{ seconds_to_sleep }}"
                  seconds_to_sleep = int(seconds_to_sleep)
                  set_progress("Sleeping for {} seconds".format(seconds_to_sleep))
                  time.sleep(seconds_to_sleep)
                  return "", "", ""

     

    Best,

    Maryam Faiz

Please sign in to leave a comment.