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

Setting

...

parameters in a PowerShell script and passing them to the next

...

step

At every change of status in job chains Job Scheduler parses a temporary file for "namh1. name=value" pairs. The "namevalue" name/value pairs will be set as order paramsparameters for subsequent jobs. The name of the temporary file is availabe available with the environment variable SCHEDULER_RETURN_VALUES. See also How to pass parameters to subsequent jobs in a job chain for an example how to pass parameters between shell jobs.

The sample example below describes a job chain with two steps. Both are running the generic job PowerShellExecutor to run a powershell presented in How to configure a generic PowerShell job to execute a PowerShell script within a JobScheduler job.

First Step: set a parameter for the next step in the job chain

Code Block
languagepowershell
titleSample script: powershell_with_parameter_set.ps1

 $A = "myParam=PowerShellParammyParamPowerShellParam"
 $A | out-file -encoding ASCII $env:scheduler_return_values
 get-content $env:scheduler_return_values
 exit $lastexitcode
Code Block

 # to change the policy for using powershellPowerShell you can use this .adm file:
 #    http://www.microsoft.com/download/en/confirmation.aspx?id=ih1. 25119

Second Step: get the parameter

...

from the

...

previous step

Code Block
languagepowershell
titleSample script: powershell_with_parameter_get.ps1
 "job-node
 "the parameter from the previous job chain node is '$envstep:"
 "myParam$env:SCHEDULER_PARAM_myParam'"
 exit $lastexitcode
Code Block
 # to change the policy for using powershellPowerShell you can use this .adm file:
 #    http://www.microsoft.com/download/en/confirmation.aspx?id=ih1. 25119

Job Chain

Image Added

 

The xml representation of the job chain:

Code Block
languagexml

 <job_chain>
    <job_chain_node state="100" job="PowerShellExecutor" next_state="150" error_state="error"/>
    <job_chain_node state="150" job="PowerShellExecutor" next_state="200" error_state="error"/>
    <job_chain_node state="success"/>
    <job_chain_node state="error"/>
 </job_chain>

related downloads:

see also:

 

Click the parameter button shown in the image above to specify the parameters for the selected job chain node.

The parameter for the first step:

Image Added

 

The parameter for the second step:

Image Added

 

The parameters for the job chain nodes are defined in a separated configuration file:

Code Block
languagexml
<settings>
      <job_chain name"powershell_with_parameter">
          <note language="de"/>
          <note language="en"/>
          <order>
              <params/>
              <process state="100">
                  <note language="de"/>
                  <note language="en"/>
                  <params>
                      <param name="Script_Filename"
                             value="${SCHEDULER_DATA}\config\live\samples\90_powerShell\powershell_with_parameter_set.ps1"/>
                      <note language="de">
                          <div xmlns="http://www.w3.org/1999/xhtml"/>
                      </note>
                      <note language="en"/>
                  </params>
              </process>
              <process state="150">
                  <note language="de"/>
                  <note language="en"/>
                  <params>
                      <param name="Script_Filename"
                             value="${SCHEDULER_DATA}\config\live\samples\90_powerShell\powershell_with_parameter_get.ps1"/>
                      <note language="de">
                          <div xmlns="http://www.w3.org/1999/xhtml"/>
                      </note>
                      <note language="en"/>
                  </params>
              </process>
          </order>
      </job_chain>
  </settings>

Related Downloads

 

...