cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
999
Views
0
Helpful
2
Replies

Is it possible to catch a PowerShell script output when an exit code is setted?

giuliodipace
Level 1
Level 1

Hi,

i'm using TEO 2.1.2 with the hotfixes from 1 to 12 already installed and i have a problem using the "Execute Windows PowerShell Script" in reading the output of a PowerShell script if an exit code is expressly setted . For example if i try to execute a script like:

the output given by the activity is only 0 (like the exit code).

This is a problem if i use a script with multiple exit codes corrisponding to different kind of situations and different outputs like the following:

if($flag -eq "0")

{

   Write-output "Hello"

   exit 0

}

elseif ($flag -eq "1")

{

   Write-output "Error 1"

   exit 1

}

else

{

  Write-output "Error 2"

  exit 2

}

or if i call an executable which exit codes i want to identify by a readable description.

Anyone knows a way to solve this issue?

Thanks a lot,

bye.

Giulio

2 Replies 2

Shaun Roberts
Cisco Employee
Cisco Employee

I would write the exit code you want ... say

Write-Host -NoNewLine "Code 1"

then you can look at the Output property of the script and then use TEO's conditionals to spin off of that.

You should look to upgrade TEO as well.. we are on version 2.3 now as the most recent release with 2.3.1 due out shortly.

If you need more help directly with this you can open a TAC case and support can give a quick look, but most likely custom stuff would be directed to AS after TAC takes a quick look.

-Shaun Roberts

CPO/CIAC Support Lead

shaurobe@cisco.com

--Shaun Roberts
Principal Engineer, CX
shaurobe@cisco.com

Thanks Shaun,

i was already looking toward this kind of approch, but i was also curious if there was a different way of doing this.

Anyway just a little annotation about your line of code, in Tidal 2.1.2 at least, Write-host doesn't work right, echo or Write-Output are fine but Write-host seems to be ignored. To the following script:

the output is

Maybe i'm missing something. Regarding an upgrade, as a devoloper i'd really like to try the improvement of the new version but this is not a decision I can make.

Thank you,

bye.

Giulio

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: