Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
titleUpdate Information
  • This article is deprecated and applies to JobScheduler releases up to 1.9
  • Starting from JobScheduler Release 1.10.5 native support for PowerShell is available
  • For detailed information see PowerShell Jobs
    Display feature availability
    StartingFromRelease1.10.5

Table of Contents
outlinh1. true
outlinh1. true
1printablefalse
2stylh1. none
3indent20px

Scope

  •  You can use the

...

  • JobScheduler PowerShell Adapter to create jobs or pre-

...

  • processing and post-processing Monitors that use

...

  • the JobScheduler API in PowerShell.
  • This feature is provided by
    • Jira
      serverSOS JIRA
      columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
      serverId6dc67751-9d67-34cd-985b-194a8cdc9602
      keyJS-1596
    • Display feature availability
      EndingWithRelease1.10
      StartingFromRelease1.9
  • Future releases will use a new interface that is available with
    • Jira
      serverSOS JIRA
      columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
      serverId6dc67751-9d67-34cd-985b-194a8cdc9602
      keyJS-1595

Requirements

  • Windows Machine with a JobScheduler installation
  • .Net Framework 4
  • Powershell PowerShell 2 or newer

Installation

  • Download the JobScheduler Powershell PowerShell Adapter from http://www.sos-berlin.com/download/scheduler/JobSchedulerPowershellAdapter.zip
  • Unzip the files file to the bin directory of your JobScheduler installation
  • Register the assembly by running

    noformat
    Code Block
    languagebash
    titleRegistration for Windows 32 bit operating systems
      C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe "[install_path]\bin\JobSchedulerPowershellAdapter.dll" /codebase
    
    Code Block
    languagebash
    titleRegistration for Windows 64 bit operating systems
      C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe "[install_path]\bin\JobSchedulerPowershellAdapter.dll" /codebase

Usage

  • The

...

  • PowerShell Adapter uses the JobScheduler COM interface.
  • Currently, neither COM

...

  • jobs nor

...

  • PowerShell jobs are supported by JOE. So,

...

  • PowerShell jobs need to be configured by manually editing XML files.

Configuring a

...

PowerShell job

  • Have the <script> use the com_class JSPowershellAdapter.JobAdapter
  • define a parameter powershell_script which that points to the location of the Powershell PowerShell job implementation
    • If the path is relative, it needs to be relative to the SCHEDULER_DATA directory
  • write a powershell Job PowerShell job implementation which that at least implements Function spooler_process()

Example job definition

Code Blocknoformat
languagexml
    <?xml versioh1. version="1.0" encoding="ISO-8859-1"?>
  
    <job>
        <params>
            <param namh1.name = "test" value = "12345"/>
            <param namh1.name = "powershell_script" value = "powershell\powershell_job.ps1"/>
        </params>    
        <script com_clash1.class = "JSPowershellAdapter.JobAdapter"/>
        <run_time once = "no"/>
    </job>

Example

...

PowerShell job script

noformat
Code Block
languagejs
collapsetrue
    Function spooler_init()
    {	
        if ($spooler_log)
        {
            $spooler_log.info("This is spooler_init()") 
            $spooler_log.info("TaskID: "+ $spooler_task.id) 
        }	
        
        return $true
    }
  
    Function spooler_open()
    {	
        $spooler_log.info("This is spooler_open()") 
        return $true;
    }
  
    Function spooler_process()
    {	
        $taskIdh1.$taskId = $spooler_task.id
        $spooler_log.info("This is spooler_process, in task id " + $taskId) 
        $order = $spooler_task.order
        if ($order)
        {        
            $orderIdh1.$orderId = $order.id
            $spooler_log.info("processing order " + $orderId) 
            return $true
        }
        return $false;
    }
  
    Function spooler_close()
    {	
        $spooler_log.info("This is spooler_close()") 
    }
  
    Function spooler_exit()
    {	
        $spooler_log.info("This is spooler_exit()") 
    }
  
    Function spooler_on_success()
    {	
        $spooler_log.info("This is spooler_on_success()") 
    }
  
    Function spooler_on_error()
    {	
        $spooler_log.info("This is spooler_on_error()") 
    }

Configuring a

...

PowerShell pre-/

...

post-processing Monitor

Only one powershell Powershell pre-/postprocessor post-processing Monitor can be configured per job.

  • Have the <monitor><script/></monitor> use the com_class JSPowershellAdapter.JobAdapter
  • define a parameter powershell_monitor_script which that points to the location of the Powershell PowerShell pre-/postprocessor post-processing Monitor implementation
    • If the path is relative, it needs to be relative to the SCHEDULER_DATA directory
  • write a powershell PowerShell pre-/postprocessor post-processing Monitor implementation

Example job definition

noformat
Code Block
languagexml
    <?xml version="1.0" encodinh1. encoding="ISO-8859-1"?>
    <job>
        <params><params>		
            <param name="powershell_monitor_script" valuh1. value="powershell\powershell_monitor.ps1"/>
        </params>
        <script language="javascript">
            <\![CDATA[
   				function spooler_process(){
        			spooler_log.info("this is javascript");
        			return false;
   				}
            ]]>
        </script>
        <monitor>    
            <script com_class="JSPowershellAdapter.JobAdapter"/>    
        </monitor>
    </job> job> 

 

Example

...

PowerShell pre-/

...

post-processing script

noformat
Code Block
languagejs
    Function spooler_task_before()
    {
        $spooler_log.info("powershell: This is spooler_task_before()")
        return $true
    }
No Format
 
    Function spooler_process_before()
	{
        $spooler_log.info("powershell: This is spooler_process_before()")
        return $true
    }
 
No Format
	Function spooler_process_after(bool $spooler_process_result)
	{
        $spooler_log.info("powershell: This is spooler_process_after with result $spooler_process_result()")
        return $spooler_process_result
    }
No Format
  
   Function spooler_task_after()
	{
        $spooler_log.info("powershell: This is spooler_task_after()")
    }

 

References

Change Management References

Jira
serverSOS JIRA
columnstype,key,issuelinks,fixversions,status,priority,summary,updated
maximumIssues20
jqlQuerylabels in (scripting-powershell)
serverId6dc67751-9d67-34cd-985b-194a8cdc9602