...
Code Block |
---|
<?xml version="1.0" encoding="ISO-8859-1"?> <job process_class="/tests/my_Agent"> <script language="powershell"> echo "job is starting" sleep 10 $files = dir * echo $files echo "job is finishing" </script> <run_time /> </job> |
...
Code Block |
---|
<?xml version="1.0" encoding="ISO-8859-1"?> <job process_class="/tests/my_Agent"> <script language="powershell"> function get_files($directory){ echo "entering function get_files" return get-childitem $directory } echo "job is starting" sleep 10 $files = get_files "*" echo $files echo "job is finishing" </script> <run_time /> </job> |
...
Code Block |
---|
<?xml version="1.0" encoding="ISO-8859-1"?> <job process_class="/tests/my_Agent"> <script language="powershell"> function spooler_process() { $spooler_log.info("job is starting") $files = get-childitem dir * echo $files $spooler_log.info("job is finishing") return $false } </script> <run_time /> </job> |
...
Code Block | ||
---|---|---|
| ||
<?xml version="1.0" encoding="ISO-8859-1"?> <job process_class="/tests/my_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() { $files = get-childitem * echo $files $spooler_log.info("hallo") return $true } ]]> </script> </monitor> <run_time /> </job> |
...
The following job shows how to set different ouputs outputs for PowerShell such as:
- Set verbose
...
- Setting PowerShell verbose for a job
- The standard PowerShell verbose setting is considered for jobs
- The example shows how to set this at lines 11-12
- Setting Debug messages for a job
- The standard PowerShell debug setting is ignored for jobs
- Instead, the current log level of the job is applied, e.g. log level "debug1" will log debug messages
- The example shows how to set this at lines 16-17
- Setting Warning Messages can be done as in line 19
- Setting Error Messages can be done as in line 22
- This throws an error and ends effectively the job with an error
- Write-Host does not work for PowerShell jobs as specified in lines 24-25
Code Block | ||
---|---|---|
| ||
<?xml version="1.0" encoding="ISO-8859-1"?> <job process_class="Agent01my_Agent" 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: # Instead the current log level of the job is applied, e.g. log level "debug1" logs debug messages $DebugPreference = "continue" 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> |
...