Helping to ensure that your text output from a worklet shows up in the activity log as expected
There are times when you include a text output into the worklet remediation code to help with troubleshooting, but it doesn't show up in the activity log as you expect. This is likely because you've directed the output to a mismatched output stream for the exit condition.
Additionally, no output from the evaluation code are displayed in the activity log because the evaluation code results are not written into the activity log. They are represented solely by the icon next to the worklet name on the device details screen. A non-zero triggers the Pending Update status, and a zero triggers the green checkmark. The evaluation code is checked each time the device does a scan.
Symptoms
- echo "Software Not Found" (or the equivalent) not showing in the activity log on an error exit condition (non-zero)
- Write-Error "Software Not Found" (or the equivalent) not showing activity log on a successful exit condition (zero)
Steps to resolution
To counter this, ensure that you are matching the output stream to the exit condition.
- To have the output shown on a successful run, make sure that it is going to the standard output stream
- PowerShell: Write-Output/Write-Host
- Bash: Redirection to the StdOut if the output didn't already go there. Example: 2>&1 at the end of the line if the output would normally go to StdErr
- To have the output shown on a failed run, make sure that it is going to the standard error stream
- PowerShell: Write-Error
- Bash: Redirection to the StdErr if the output didn't already go there. Example: 1>&2 at the end of the line if the output would normally go to StdOut