...
Code Block | ||
---|---|---|
| ||
echo "job is starting" abcde echo "job is finishing" |
The same example would be working in Powershell the following way:
Code Block | ||
---|---|---|
| ||
echo "job is starting" try{abcde} catch{Break} echo "job is finishing" |
Note |
---|
This type of differences described above will be furhter supported like this from JobScheduler and seen as natural differences between the Shell and Powershell languages. |
...
Example: Powershell as a Shell
Example 1: A simple job with some scripting analogue to basic Shell jobs might look like this:
Code Block | collapse | true
---|
<?xml version="1.0" encoding="ISO-8859-1"?> <job process_class="/tests/Agent"> <script language="powershell"> echo "job is starting" sleep 10 $files = dir * echo $files echo "job is finishing" </script> <run_time /> </job> |
Example 2: A basic PowerShell job including that calls a function might look like this:
Code Block |
---|
<?xml version="1.0" encoding="ISO-8859-1"?> <job process_class="/tests/Agent"> <script language="powershell"> |
...
function get_files($directory){
echo "entering function get_files"
return get-childitem $directory
}
echo "job is starting"
sleep 10
$files = get_files "*"
echo $files
echo "job is finishing"
</script>
<run_time />
</job> |
Example: Powershell API Jobs
tbd
An API Job (analogue to Javascript jobs)
Code Block | ||
---|---|---|
<?xml version="1.0" encoding="ISO-8859-1"?>
<job | ||
Code Block | ||
| ||
<job process_class="my_process_class/tests/Agent"> <script language="powershell"> <![CDATA[ Import-Module JobScheduler use-master myjobscheduler:4444 get-status ]]> function spooler_process() { $spooler_log.info("job is starting") $files = get-childitem dir * echo $files $spooler_log.info("job is finishing") return $false } </script> <run_time /> </job> |
Example: Combination of
...
both
Example 1:tbd
Code Block | ||
---|---|---|
| ||
<?xml version="1.0" encoding="ISO-8859-1"?> <job process_class="/tests/Agent"> <script language="powershell"> echo job is starting sleep 10 echo job is finishing </script> <monitor name="process_powershell" ordering="0"> <script language="powershell"> <![CDATA[ function spooler_process_before() { $env:files = get-childitem * echo $files $spooler_log.info("hallo") return $false } ]]> </script> </monitor> <run_time /> </job> |
...