:READ statement in script or prescript tab of JOBS with powershellscript runs into error

Document ID : KB000088482
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
:READ statement in script or prescript tab of JOBS with powershellscript runs into error
Resolution:

Symptoms

 

The issue occurs on jobs with powershell activated when they have a :READ statement in script or prescript, which passes its values to the Shellscript

Error occurs as follows:

Unexpected token 'Input' in expression or statement.
At agentpath\reportfile.ps1:2 char:9
+ ' Input <<<< '0001' used from input buffer -> '&JobNameParam#'='JOBNAME'.
+ CategoryInfo : ParserError: (Input:String) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken

Job fails then with Ended abnormally.

 


 

 

Cause

 

This is caused because the Interpreter for powershellscripts sees the Interpreter for Automic readcommands as script and runs in error then.


 

 

Resolution

There are basicly two ways to solve the issue one in the Jobobject itself (NOTE only possible if used in JOBS object) and the second one by changing the HEADER.WINDOWS Object in Client 0:

1.) Solution in JOBS object:

adding the parameter "I" to the :READ function;

"I" (only for Jobs)
:READ statements and user inputs are generally documented in the generated Job object in the form of REMARK lines. By specifying the option "I",
this documentation will be suppressed.

-please find further information in Automic script manual, searching for :READ command

2.) preparing the HEADER.WINDOWS Object in client 0 for the usage of :READ command on powershell scripts

Example:

 :IF &UC_WIN_TYP = "BAT"
 :   set &UC_REM_PRF = 'REM '
 :else
 :   set &UC_REM_PRF = "# "