Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.

Control with powershell exit or returncode

Idea ID 1663592

Control with powershell exit or returncode

With powershell i want to have control with exitcode / returncode.

For example:

I have a flow with an external powershell call like

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -ExecutionPolicy Bypass -file ${Robotorium/PoSH/file.ps1-Server ${ARG-Servername}

I will use an powershell exit with errorcode to use further in the flow

I have tried more exit strategies within Powershell

- exit 1
- Return 1
- break
- throw #HPoo sees this as an error in the script.

I will catch the errorlevel in the flow, because i can use it for error-handling in the flow.
Something like
Errorlevel > 1 = error.
Errorlevel = 0, everything OK

Please create an option in HPoo to handle with this mechanism.

We are a automation team for our company.

Best regards,




AndreiTruta Outstanding Contributor.
Outstanding Contributor.
Status changed to: Waiting for Votes

I am in strong support for this, when we want to have controller errors or exits in Powershell, So, OO Flow should not interfere, I saw some irrlevant errors stop the executions while for me those are not of any importance and Script should continue.

Rabobank Super Contributor.
Super Contributor.

Is there any update about this one? We really would like to retrieve the actual returnCode that's returned by the PS1 script. 

Micro Focus Expert
Micro Focus Expert

Hello Rabobank,

Thank you for voting this requirement.

The requirement is still in Waiting for Votes state and was not yet considered for the next releases. 

Is your use case exact same use case as described by Jaxoft  or there is a variance to it?  

Also, how do you handle this use case today?

Thank you,


Rabobank Super Contributor.
Super Contributor.

Hello Lucian,

Our requirement is similar as described by Jaxoft. We're currently using the "returnResult" output in combination with string comparators to determine the right followup actions of a flow. 

I know that the "SSH Command" Operation (uuid=0b066b79-d65c-4da9-8ed4-edf50f378950) has a similar method to retrieve the actual exitStatus. This operations got both a returnCode output (which is just 0 or -1) and an actual exitStatus output that is returned by the command or script. We're using exitStatus to determine the right followup actions of the related flow. 

SSH Command.PNG





Kind regards,

Thijs de With

Micro Focus Expert
Micro Focus Expert
Status changed to: Under Consideration
Micro Focus Expert
Micro Focus Expert
Status changed to: Delivered

Available here:  https://marketplace.microfocus.com/itom/content/oo-base-content

Like always, we are looking forward for your feedback! 

drodiger1 Regular Contributor.
Regular Contributor.

For Powershell operations, you can always exit with exception and returnCode will not be 0, if I am correct. So there is nothing you should improve on Powershell operation in OO CP.

You only need to improve your Powershell skills 😉

What we started to do is following:


Most of the standard operations return objects which can be converted into JSON.

So, if we are creating special function, we would use:

- create new PSObject

$resultJson = New-Object -TypeName PSObject;

- add property members

$resultJson | Add-Member -NotePropertyName Status -NotePropertyValue "ERROR"

- return this object

Return $resultJson


So, when you call function that creates this object and returns it, you can pipe it into ConvertTo-Json operation and get JSON as result, which you can use with existing JOSN operations in Base CP...

So, result above would be {"Status":"ERROR"}.

And you can extend PSObject with additional $object | Add-Member ....operations to return more data


The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.