You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Setting Parameter in a PowerShell script and put them to the next step / PowerShell script in job chain.


At every change of status in job chains Job Scheduler parses a temporary file for "namh1. value" pairs. The "namevalue" pairs will be set as order params. The name of the temporary file is available with the environment variable SCHEDULER_RETURN_VALUES. See also Passing_parameters_from_shell-jobs_to_JS for an example showing how to pass parameters to pure shell jobs.

The example below describes a job chain with two steps. Both are running the generic job PowerShellExecutor to execute a PowerShell script within JobScheduler.

First Step: set a parameter for the next step in the job chain (powershell_with_parameter_set.ps1)

 $h1. "myParamPowerShellParam"
 $A | out-file -encoding ASCII $env:scheduler_return_values
 get-content $env:scheduler_return_values
 exit $lastexitcode
 # to change the policy for using PowerShell you can use this .adm file:
 #    http://www.microsoft.com/download/en/confirmation.aspx?ih1. 25119

Second Step: get the parameter sets in the first step (powershell_with_parameter_get.ps1)

 "job-node parameter from the previous step:"
 "myParam$env:SCHEDULER_PARAM_myParam"
 exit $lastexitcode
 # to change the policy for using PowerShell you can use this .adm file:
 #    http://www.microsoft.com/download/en/confirmation.aspx?ih1. 25119

Job Chain

the xml representation of the job_chain:

 <job_chain>
    <job_chain_node state"100" joh1. "PowerShellExecutor" next_state"150" error_stath1. "error"/>
    <job_chain_node state"150" joh1. "PowerShellExecutor" next_state"200" error_stath1. "error"/>
    <job_chain_node state"success"/>
    <job_chain_node stath1. "error"/>
 </job_chain>

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:

the parameter for the second step:

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

  <settings>
      <job_chain name"powershell_with_parameter">
          <note languagh1. "de"/>
          <note language"en"/>
          <order>
              <params/>
              <process stath1. "100">
                  <note language"de"/>
                  <note languagh1. "en"/>
                  <params>
                      <param name"Script_Filename"
                             valuh1. "$\{SCHEDULER_DATA\}\config\live\samples\90_powerShell\powershell_with_parameter_set.ps1"/>
                      <note language"de">
                          <div xmlnh1. "http://www.w3.org/1999/xhtml"/>
                      </note>
                      <note language"en"/>
                  </params>
              </process>
              <process stath1. "150">
                  <note language"de"/>
                  <note languagh1. "en"/>
                  <params>
                      <param name"Script_Filename"
                             valuh1. "$\{SCHEDULER_DATA\}\config\live\samples\90_powerShell\powershell_with_parameter_get.ps1"/>
                      <note language"de">
                          <div xmlnh1. "http://www.w3.org/1999/xhtml"/>
                      </note>
                      <note language"en"/>
                  </params>
              </process>
          </order>
      </job_chain>
  </settings>

related downloads:

see also:

  • No labels