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 <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/job.xml job ]title="Execute a PowerShell Script"
      order="yes"
      stop_on_error="no">
     <script <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/script.xml 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  <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/order.xml monitor ]name="configuration_monitor"
              ordering="0">
         <script <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/script.xml script ]java_class="sos.scheduler.managed.configuration.ConfigurationOrderMonitor"
                 language="java"/>
     </monitor>
     <run_time <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/run_time.xml 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 <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/order.xml order ]title="Executes the File PowerShell-Hallo.ps1">
     <params>
 <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/params.xml params]>
          <param <[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/param.xml param ]name="Script_Filename"
                value="$\{SCHEDULER_DATA\}\config\live\PowerShell\Powershell-Hallo.ps1"/>
     </params>
     <run_time<[http://www.sos-berlin.com/doc/en/scheduler.doc/xml/run_time.xml 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.

...