Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Calling Order parameters or Job parameters

Calling parameters works differently for PowerShell jobs than for Shell jobs, using $env: for PowerShell instead of % as for Shell:

Code Block
# Example Shell: 
myscript.cmd %SCHEDULER_PARAM_NAME1%

# Example PowerShell: 
myscript.cmd $env:SCHEDULER_PARAM_NAME1

...

Setting a parameter in an order (for instance parameter "name1" with the value "value1") and returning the parameter to the order so that the next job chain node uses the new value. This For PowerShell this only works using the API methods for PowerShell. The differences are shown below $spooler_task.order():

Code Block
# Example Shell: 
echo name1 = value2 >> %SCHEDULER_RETURN_VALUES%

# Example PowerShell: 
$spooler_task.order().params().set_value("name1","value2")

Exit Code Handling

Example: let's consider a simple job such as:

Code Block
linenumberstrue
<?xml version="1.0" encoding="ISO-8859-1"?>
 
<job  process_class="/tests/Agent">
    <script  language="powershell">
 
	echo "job is starting"
	abcde
	echo "job is finishing"
 
    </script>
      <run_time />
</job>

 

This job The following example throws no error in a Shell job but it breaks at line 2 and ends in an error for a PowerShell job with the following message: 

echo "job is starting" abcde echo "job is finishing"
Code Block
linenumberstrue
2016-06-22 14:41:38.359+0200 [ERROR] Die Benennung "abcde" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang.

 

The same example would be working in PowerShell the following way:

Code Block
linenumberstrue
<?xml version="1.0" encoding="ISO-8859-1"?>
 
<job  process_class="/tests/Agent">
    <script  language="powershell">
 
	echo "job is starting"
	try { abcde }
	catch {}
{echo "exception line 7: abcde is either a cmdlet nor a variable"}
	echo "job is finishing"
 
    </script>
      <run_time />
</job>
Note

This type of differences described above will be further supported like this from JobScheduler and seen as natural differences between the Shell and PowerShell languages.