Versions Compared

Key

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

...

Code Block
<?xml version="1.0" encoding="ISO-8859-1"?>
<job  process_class="my_Agent">
    <script  language="powershell">
	
	# PowerShell function used for the main job
	function get_files($directory){
		echo "entering function get_files"
		return get-childitem $directory
	}
	
	echo "job is starting"
	sleep 10
 
	# the same structure as in the example 1 but using a PowerShell function
	$files = get_files "my_directory"
	echo $files
	echo "job is finishing"
	
    </script>
    <run_time />
</job>

Example: PowerShell API JobsJobs 

A basic API Job might look like this:

Code Block
<?xml version="1.0" encoding="ISO-8859-1"?>

<job  process_class="my_Agent/tests/Agent" stop_on_error="no">
    <script  language="powershell">
	
	        <![CDATA[
function spooler_process(){
		
	# set variables to store the information about job and task 	
	$jobName = $spooler_job.name()
	{
	$jobTitle = $spooler_job.title()
	$taskID = $spooler_task.id()
	
	# show the information about job and task
	echo "job $jobName with title $jobTitle is starting"
		$filesecho = get-childitem dir *"task ID is $taskID"
		echo $files 
		echo "job is finishing"
		
		# for standalone jobs set to false / for order jobs set to true
		return $false
	}}
        ]]>
    </script>
    <run_time />
</job>

...