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.