Skip to main content

HelloID

Process logging in PowerShell target connectors

In PowerShell target connectors (both v1 and v2), Process logs is done through native PowerShell cmdlets; see Logging cmdlets.

Alternatively, custom messages can be written to the Audit logs; see Manually writing messages into audit logs.

Logging errors

Use Write-Warning when an error occurs. Include the script line number, the line of code where the error occurred, and the full error record. For example:

Write-Warning "Error at Line '$($ex.InvocationInfo.ScriptLineNumber)': $($ex.InvocationInfo.Line). Error: $($ex.Exception.Message)"

Do not use Write-Error. It marks the action as failed after enforcement, even if the script sets $outputContext.Success to true, which indicates the action completed successfully.

Custom messages written to the Audit logs in the event of an error must include a user-friendly description of the issue.

Where the logs appear

Log messages appear in the Preview area of the script editor, under Logs.

When the script runs in production, it depends on the script type whether and where log messages are shown:

Note

Process logs are retained for 30 days.