Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Return code for Powershell script from vCO

$
0
0

Hello,

 

I have been trying to get the return code of a Powershell script executed from vCO using the plugin. I can capture the output but I would like to get the script exit code (as specified by an exit statement on the PS script).

 

Here is my vCO code:

 

try {
    session = psHost.openSession();
    var script =  '& "' + externalScript + '" ' + arguments;
    result = session.invokeScript(script);
    if (result.invocationState  == 'Failed'){
        throw "PowerShellInvocationError: Errors found while executing script \n"  + result.getErrors();
    }
    //Show result
    var psOutput = result.getHostOutput();
    var psErrors = result.getErrors();
    var psResults = result.getResults();
    System.log("Output:"+psOutput);
    System.log("Errors:"+psErrors);
    System.log("Results:"+psResults);
} finally {
    if (session){
        psHost.closeSession(session.getSessionId());
    }
}

 

As I mentioned psOutput works fine and contains the std output, but I always get an empty string for psErrors and a NULL value for psResults, even when I change my script to deliberately exit with an error code different than 0.

 

Anybody has the exit code working?

 

 

Thanks,

 

 

Juan.


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>