Versions Compared

Key

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

...

Display feature availability
StartingFromRelease1.10.5

...

PowerShell as a Shell

As mentioned before, Powershell Jobs should be seen as the analogy for Shell Jobs in the future. That means, every Shell job should be able to be (with any or few changes) converted into a PowerShell job. 

Nevertheless, there are some compatibility issues as described below.

Calling Order parameters or Job parameters

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

# Example PowerShell: 
myscript.cmd $env:SCHEDULER_PARAM_NAME1

Returning a parameter an its value to an Order

Code Block
# Example Shell: 
echo NAME1 = VALUE1 >> %SCHEDULER_RETURN_VALUES%

# Example PowerShell: 
echo "NAME1 = VALUE1" >> $env:SCHEDULER_RETURN_VALUES
$spooler_task.order.params.set_value( 'NAME1', 'VALUE1')

Exit Code Handling

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:

Code Block
linenumberstrue
echo "job is starting"
abcde
echo "job is finishing"

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

Code Block
linenumberstrue
echo "job is starting"
try { abcde }
catch {}
echo "job is finishing"

...

.

Examples

Example: PowerShell as a Shell

...

Info
  • The feature is only available in case your Agent is running on a machine with PowerShell available
  • For more information about how to set the PowerShell CLI modules on your Agent, have a look at PowerShell Command Line Interface - Introduction

 

Differences between PowerShell and Shell

As mentioned before, Powershell Jobs should be seen as the analogy for Shell Jobs in the future. That means, every Shell job should be able to be (with any or few changes) converted into a PowerShell job. 

Nevertheless, there are some compatibility issues as described below.

Calling Order parameters or Job parameters

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

# Example PowerShell: 
myscript.cmd $env:SCHEDULER_PARAM_NAME1

Returning a parameter an its value to an Order

Code Block
# Example Shell: 
echo NAME1 = VALUE1 >> %SCHEDULER_RETURN_VALUES%

# Example PowerShell: 
echo "NAME1 = VALUE1" >> $env:SCHEDULER_RETURN_VALUES
$spooler_task.order.params.set_value( 'NAME1', 'VALUE1')

Exit Code Handling

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:

Code Block
linenumberstrue
echo "job is starting"
abcde
echo "job is finishing"

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

Code Block
linenumberstrue
echo "job is starting"
try { abcde }
catch {}
echo "job is finishing"
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.