KBI 312090 New Feature: How to Report Failure Status in PowerShell Script Action


Argent Omega 2.2A-2307-B or later


Sunday, 24 September 2023


PowerShell Script Action might have very complicated logic. Besides coding error that PS failed with exception errors, script should report failure status for condition even script itself completes without any error. For example, a script back up file as follows:

$file = “C:\some_important_file”
if (Test-Path $file) {
Copy-Item -Path $file -Destination ($file + “.bak”)

The script completes no matter whether the file exists. Say user wants to report the failure status if the file does not exist.

It can be done by using method $PSPlayer.SetErrorStatus.

Technical Background

When a PowerShell Script Action failed, system administrator would be notified as well as being logged in Alert status on Event Console.

The status of PowerShell Script Action is also critical in implementing Workflow. Workflow relies on the status to take ‘On Success’ step or ‘On Failure’ step.


Upgrade to Argent Omega 2.2A-2307-B (Build: 2.2.2309.24) or later