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

Compare with Current View Page History

« Previous Version 2 Next »

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:

 <job title="Execute a PowerShell Script"
      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%
         ]]>
     </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:

 <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.

  • No labels