...
tbd
Code Block | ||
---|---|---|
| ||
Example: Combination of both (Job with Monitors)
tbd
Code Block | ||
---|---|---|
| ||
<?xml version="1.0" encoding="ISO-8859-1"?>
<job process_class="/tests/Agent">
<script language="powershell">
echo job is starting
sleep 10
echo job is finishing
</script>
<monitor name="process_powershell" ordering="0">
<script language="powershell">
<![CDATA[
function spooler_process_before()
{
$env:files = get-childitem *
echo $files
$spooler_log.info("hallo")
return $false
}
]]>
</script>
</monitor>
<run_time />
</job> |
Example: PowerShell Job with Debug output
Code Block | ||
---|---|---|
| ||
<?xml version="1.0" encoding="ISO-8859-1"?>
<job process_class="Agent01" stop_on_error="no">
<settings >
<log_level ><![CDATA[debug1]]></log_level>
</settings>
<script language="powershell">
<![CDATA[
# Standard PowerShell verbose setting is considered for jobs:
$VerbosePreference = "continue"
Write-Verbose "job: this is some verbose output"
# Standard PowerShell debug setting is ignored for jobs:
# $DebugPreference = "continue"
# Instead the current log level of the job is applied, e.g. log level "debug1" logs debug messages
Write-Debug "job: this is some debug output"
Write-Warning "job: this is a warning"
# This can be used to throw an error
# Write-Error "job: this is an error"
# This does not work: Use of Write-Host is not allowed
# Write-Host "job: this is some output"
]]>
</script>
<run_time />
</job> |
Extras: CLI for Powershell Jobs
Info |
---|
<job process_class="my_process_class"> Import-Module JobScheduler
<run_time /> |