How to write log in SD Job Output in powershell Script ?
book
Article ID: 282589
calendar_today
Updated On: 05-14-2024
Products
CA Client Automation - IT Client Manager
CA Client Automation
Issue/Introduction
SD Package is running a powershell script as install procedure. How to write log message from powershell script to SD Job Output ?
Environment
Client Automation - All Versions
Resolution
Here is a method example to do this (example with 2 parameters and SD Job Output file is in second parameter).
1- Create a SD Package with the powershell script in the source.
Example of script
Param ($FirstParam, $jobOutput)
Function Log
{
Param ([string]$linea)
$linea = (Get-Date).ToLongTimeString()+" : $($linea)"
Add-content $jobOutput -value $linea
}
Log "Start of script"
Log "First Param is $FirstParam"
Log "Output File is $jobOutput"
Log "End of script"
This script contains a function Log to write a string into a file
And the following line set the 2 parameters in variable FirstParam and jobOutput
Param ($FirstParam, $jobOutput)
This line must be the first line of the script.
2- Create an install procedure with the powershell script.
And put install as first parameter and "$rf" in second parameter
3- When this package is sent to a computer the log generated by the powershell script are written in the SD Job Output :
Feedback
Was this article helpful?
thumb_up
Yes
thumb_down
No