...
Using the Job Scheduler Powershell Adapter, it's possible to create jobs or monitors that use the JobScheduler API in Powershell.
Requirements
- Windows Machine with a JobScheduler installation
- .Net Framework 4
- Powershell 2
Installation
- Download the JobScheduler Powershell Adapter from here (link)
- Unzip the file to the bin directory of your JobScheduler installation
- Register the assembly by runningnoformat
Code Block |
---|
C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe [install_path]\bin\JobSchedulerPowershellAdapter.dll /codebase
|
Usage
The Powershell Adapter uses the JobScheduler COM interface.
...
- Have the
<script>
use the com_class JSPowershellAdapter.JobAdapter
- define a parameter
powershell_script
which points to the location of the Powershell Job implementation - write a powershell Job implementation which at least implements
Function spooler_process()
Example job definition
No Formatcode |
---|
<?xml versioh1. version="1.0" encoding="ISO-8859-1"?>
|
<job>
Code Block |
---|
<job> |
No Format |
---|
<params>
<param namh1. name="test" value="12345"/>
<param namh1. name="powershell_script" value="powershell\powershell_job.ps1"/>
</params>
<script com_clash1. class="JSPowershellAdapter.JobAdapter"/>
<run_time once="no"/>
</job>
|
Example Powershell Job Script
No Formatcode |
---|
Function spooler_init()
\{
if ($spooler_log)
\{
$spooler_log.info("This is spooler_init")
$spooler_log.info("TaskID: "+$spooler_task.id)
\}
return $true
\}
|
Code Block |
---|
Function spooler_open() |
...
No Format |
---|
\{
$spooler_log.info("This is spooler_open")
return $true;
\}
|
Code Block |
---|
Function spooler_process() |
...
No Format |
---|
\{
$spooler_log.info("This is spooler_process")
return $false;
\}
|
Code Block |
---|
Function spooler_close() |
...
No Format |
---|
\{
$spooler_log.info("This is spooler_close")
\}
|
Code Block |
---|
Function spooler_exit() |
...
No Format |
---|
\{
$spooler_log.info("This is spooler_exit")
\}
|
Code Block |
---|
Function spooler_on_success() |
...
No Format |
---|
\{
$spooler_log.info("This is spooler_on_success")
\}
|
Code Block |
---|
Function spooler_on_error() |
...
No Format |
---|
\{
$spooler_log.info("This is spooler_on_error")
\}
|