Powershell parameters - VisualCron - Forum

Community forum

osirisja
2011-08-30T15:50:59Z
Hello all again

I'm still on about Powershell 😉 and hopefully I can have some guidance (especially from Henrik if you are available)?

I have VC calling some PoSh scripts and it all seems to be working well, apart from the ability to:
a) Feed errors back in to VC
b) Pass parameter values back from Powershell in to VC Variables.

I see having this ability as being a huge win for us (along with Loops) as this will go a long way towards reducing our dependency on Perl scripts all over the enterprise.

What range of Powershell functionality will be provided in the next release, and, probably more importantly, when will this likely be available?

Many thanks

Andy
Support
2011-08-30T16:59:52Z
Andy,

for a) - did you test this version along with write-error command? http://www.visualcron.co....aspx?g=posts&t=1951 

What kind parameters are you thinking about? From where are they coming?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
osirisja
2011-08-31T09:27:37Z
Hi Henrik

Okay - spent the morning trying your suggestions - installed the VC Version you linked to. Changed my PoSh script to call the 'write-error' cmdlet, but still not getting any Failed result from my external.

The problem is likely to be my poor understanding of both PowerShell and VisualCron at this stage, so forgive me if I am overlooking the obvious.

My PoSh script is as follows:
======================
$currpath = "{TRIGGER(Active,LastTrigger,File.Result.TriggerFolder)}"
$currfile = "{TRIGGER(Active,LastTrigger,File.Result.Name)}"
$matchfile = "C:\@@Trigger\Profile\FileAcct.csv"
$outfile = "C:\@@Trigger\Profile\$currfile.CSV"
$exe = "c:\isis_V72\pdew3700\pdew3.exe"
$prj = "R:\ISIS_RES\docdef\VIPTemplates.prj /DocDef"

Invoke-Expression "$exe $prj"

if($? -eq "False")
{
write-error -Message "Error while running $DDef."
write-error -Message "Error RC: $?"
}
=============================

(passing the VC variables from previous tasks into the script works great by the way!!!!)

So basically, I am calling an external EXE. When the PoSh task runs, the EXE is called and I am getting the 'EXE's Log file written to STDOUT and STDERR however, the EXE returns a Return Code (RC) of '8' which means it failed - here is the last part of the log file:
=============================
.
.
.
2011-08-31/10:10:24.032 0001/0004 PPDE7097E (VIPTemplates/348) RN:1 LISTOUT S:\@@TRIGGER\LOG\DEFILELIST.DAT cannot be created;;
2011-08-31/10:10:24.032 0001/0004 PPDE7088E (VIPTemplates/348) RN:1 LISTOUT DPRF not opened;;
2011-08-31/10:10:24.032 0001/0004 PPDE7281F (VIPTemplates/273) RN:1 Aaaargh >>>>>>>>PPDE7097E (VIPTemplates/348) RN:1 LISTOUT S:\@@TRIGGER\LOG\DEFILELIST.DAT cannot be created;;
2011-08-31/10:10:24.032 0001/0004 PPDE7195F (*/0) RN:1 Job aborted due to operator action;;
2011-08-31/10:10:24.032 0001/0004 PPDE1004I (*/0) RN:1 Generator returns RC:8;;
2011-08-31/10:10:24.032 0001/0004 PPDE1090I (*/0) RN:1 Papyrus Docexec V.7.02/w3 Struct align 4;;
2011-08-31/10:10:24.032 0001/0004 PPDE1091I (*/0) RN:1 CPU Time : 0.047 sec (1.000 sec);;
2011-08-31/10:10:24.032 0001/0004 PPDE1092I (*/0) RN:1 Generated : 0 document(s);;
2011-08-31/10:10:24.032 0001/0004 PPDE1093I (*/0) RN:1 Generated : 0 pages 0.000 Pages/sec (0.000 Pages/sec);;
2011-08-31/10:10:24.032 0001/0004 PPDE1094I (*/0) RN:1 Elapsed Time without key checking 0.340 sec;;
2011-08-31/10:10:24.032 0001/0004 PPCO9804I (DE) Converter Module ended with Error 8!;;
2011-08-31/10:10:24.032 0001/0004 PPST9901I Module started at: 2011-08-31/10:10:22.;;
2011-08-31/10:10:24.032 0001/0004 PPST9902I Module finished at: 2011-08-31/10:10:24.;;
2011-08-31/10:10:24.032 0001/0004 PPST9903I Duration time: 00:00:02.;;
2011-08-31/10:10:24.052 0001/0001 PPST9933I Starter Module finished with RC=8;;

=============================================

What I need to happen is for the Failure to cause the Task to error so that it can call a 'Notify' Job to email the error.

If I call this exact same EXE with the same parameters from a DOS batch file using an Execute (External Application) Task, it works perfectly and my Failure Email is sent, but my preference is to keep everything internal to VC.

So where am I going wrong?

As for the parameters, I want my PoSh script to run - for example this script (which works great):
===================
import-Csv $matchfile | Where-Object {$currfile -match $_.FileMatch} | Select-Object -First 1 | Out-File $outfile | %{$fm = $_.FileMatch; $cID = $_.Cust_id; $appRoot = $_.'App Root'; $DDef = $_.DocDef;}
===================

I am setting variables from a CSV file (eg, $fm, $cID, $DDef etc) - IS there a way to pass those variables back to the next VC task?

Thanks

Andy
Support
2011-08-31T09:48:59Z
The problem is that when you mentioned that errors could not be captured we started implementing that support. Our goal, was at that time be able to capture error text and we thought that this was what you wanted. There is a big difference with capturing error text and capturing an error. From our understanding Powershell never really throws an error.

I assume that you got the error text in the Standard error column of your Task?


But, in order to throw a VisualCron error we could simply throw an error if there is any content in the standard error (that we just captured). It probably makes sense and most users would agree on this as a workaround. We will add that for next version.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2011-08-31T10:21:48Z
Try this attached version which contains the fix I am talking about.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
osirisja
2011-08-31T10:26:35Z
Hi Henrik

The Log file I sent to you previously was actually from STDOUT. The Log text in STDERR is always produced regardless of whether there is an error or not and the strange thing is that it doesn't contain the Error messages that are in STDOUT.... For example:
==============
2011-08-31/10:32:29.984 0001/0004 PPCS0226I Set ISIS_PCS_LOGMODE=M,S7 [pcsdll\pcsapp.cpp,438]
2011-08-31/10:32:30.371 0001/0004 PPST9991I 2011-08-31/10:32:28;00:00:02;RC=8;DE;NO Inputfile;NO Targetfile;0;; [starter\dllthre.cpp,2734]
2011-08-31/10:32:30.511 0001/0001 PPCS8099I Application end. [pcsdll\pcs.cpp,778]
==============

Cheers

Andy
osirisja
2011-08-31T10:44:13Z
Henrik

Thanks - very impressive turn around with the fix!

I tried this version and it does exactly as you suggested - fails the task whenever STDERR contains any output - perfect! Now, what I need to figure out is how to stop PoSh writing output to STDERR when there isn't an error!

I also noticed that the STDERR log is being written twice in this version - separated by the text "Exception in Task':
===============
2011-08-31/11:39:38.758 0001/0001 PPCS8005I Application C:\isis_V72\pdew3700\pdew3.exe started (with PCSDLL cleanup enabled, PCSDLL date: '2011-05-18 (build:7.02.0.11201)'). [pcsdll\pcs.cpp,420]2011-08-31/11:39:38.778 0001/0001 PPCS8006I Commandline parameters: R:\ISIS_RES\docdef\VIPTemplates.prj /DocDef [pcsdll\pcs.cpp,429]
2011-08-31/11:39:38.778 0001/0001 PPCS8010I ISIS STARTER, Version V.7.02/w3 of '2011-05-18 (build:7.02.0.11201)' [interf\modctrl.hpp,33]
2011-08-31/11:39:38.778 0001/0001 PPCS8020I Windows/Intel (x86) 32 bit [interf\modctrl.hpp,34]
2011-08-31/11:39:38.778 0001/0001 PPCS8030I (C) Copyright ISIS Papyrus Software AG 1997-2011 [interf\modctrl.hpp,35]
2011-08-31/11:39:38.778 0001/0001 PPCS0226I Set ISIS_PCS_LOGMODE=M,S7 [pcsdll\pcsapp.cpp,438]
2011-08-31/11:39:38.778 0001/0001 PPCS8002I PCSDATA c__isiscommv7_w3_ISIS_PCS_20110315_ShMem_PCSDATA on address 01DF0000 used. [pcsdll\pcs.cpp,567]
2011-08-31/11:39:39.842 0001/0004 PPCS0226I Set ISIS_PCS_LOGMODE=M,S7 [pcsdll\pcsapp.cpp,438]
2011-08-31/11:39:40.232 0001/0004 PPST9991I 2011-08-31/11:39:38;00:00:02;RC=0;DE;NO Inputfile;NO Targetfile;0;; [starter\dllthre.cpp,2734]
2011-08-31/11:39:40.322 0001/0001 PPCS8099I Application end. [pcsdll\pcs.cpp,778]

Exception in Task:

2011-08-31/11:39:38.758 0001/0001 PPCS8005I Application C:\isis_V72\pdew3700\pdew3.exe started (with PCSDLL cleanup enabled, PCSDLL date: '2011-05-18 (build:7.02.0.11201)'). [pcsdll\pcs.cpp,420]2011-08-31/11:39:38.778 0001/0001 PPCS8006I Commandline parameters: R:\ISIS_RES\docdef\VIPTemplates.prj /DocDef [pcsdll\pcs.cpp,429]
2011-08-31/11:39:38.778 0001/0001 PPCS8010I ISIS STARTER, Version V.7.02/w3 of '2011-05-18 (build:7.02.0.11201)' [interf\modctrl.hpp,33]
2011-08-31/11:39:38.778 0001/0001 PPCS8020I Windows/Intel (x86) 32 bit [interf\modctrl.hpp,34]
2011-08-31/11:39:38.778 0001/0001 PPCS8030I (C) Copyright ISIS Papyrus Software AG 1997-2011 [interf\modctrl.hpp,35]
2011-08-31/11:39:38.778 0001/0001 PPCS0226I Set ISIS_PCS_LOGMODE=M,S7 [pcsdll\pcsapp.cpp,438]
2011-08-31/11:39:38.778 0001/0001 PPCS8002I PCSDATA c__isiscommv7_w3_ISIS_PCS_20110315_ShMem_PCSDATA on address 01DF0000 used. [pcsdll\pcs.cpp,567]
2011-08-31/11:39:39.842 0001/0004 PPCS0226I Set ISIS_PCS_LOGMODE=M,S7 [pcsdll\pcsapp.cpp,438]
2011-08-31/11:39:40.232 0001/0004 PPST9991I 2011-08-31/11:39:38;00:00:02;RC=0;DE;NO Inputfile;NO Targetfile;0;; [starter\dllthre.cpp,2734]
2011-08-31/11:39:40.322 0001/0001 PPCS8099I Application end. [pcsdll\pcs.cpp,778]
=======================================
Support
2011-08-31T10:55:00Z
Right, we will fix the double output. Maybe you can live with that for the next release.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
osirisja
2011-08-31T11:09:39Z
That's great Henrik.

On a personal note, can I just say that I am impressed with what I am seeing here - first of all with the product itself and the plans you have for it, and also with the support that you and of course other posters such as Erik have provided.

As an independent consultant evaluating and implementing tools such as VC for my customers, it sure makes my job a lot easier :-)

Cheers

Andy
Support
2011-08-31T11:13:25Z
Thanks for the feedback!
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2011-08-31T14:36:14Z
We have uploaded the new update here. Now it should only write the error once:

http://www.visualcron.co....aspx?g=posts&t=1969 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top