Versions Compared

Key

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

...

PowerShell is the Scripting shell of the Windows world. A PowerShell script can be used in Jobs as easy as other shell scripts.

An example:

Code Block

...


 <job title="Execute a PowerShell Script"

...

Code Block
      order="yes"
      stop_on_error="no">
     <script language="shell">
         <![CDATA[
 echo SCHEDULER_DATA = %SCHEDULER_DATA%

...


 echo SCHEDULER_PARAM_SCRIPT_FILENAME = %SCHEDULER_PARAM_SCRIPT_FILENAME%

...


 
 powershell get-ExecutionPolicy

...


 powershell -nologo -NonInteractive -noprofile -file "%SCHEDULER_PARAM_SCRIPT_FILENAME%" "%SCHEDULER_PARAM_SCRIPT_FILENAME%"

...


 exit %errorlevel%

...

Code Block
         ]]>
     </script>
     <monitor name="configuration_monitor"
              ordering="0">
         <script java_class="sos.scheduler.managed.configuration.ConfigurationOrderMonitor"
                 language="java"/>
     </monitor>
     <run_time/>
 </job>

This job is an order-driven job and therefore the parameters for this job comes from an order like that one below:

Code Block

 <order title="Executes the File PowerShell-Hallo.ps1">
     <params>
         <param name="Script_Filename"
                value="$\{SCHEDULER_DATA\}\config\live\PowerShell\Powershell-Hallo.ps1"/>
     </params>
     <run_time let_run="no"/>
 </order>

Within the order the value of the parameter Script_Filename, which specify the name of the script to be executed, will be passed to the job as an environment variable.</job>