Active IQ Unified Manager Discussions

Show command in workflow as failed but continue

jakob_scheidler
2,662 Views

Hello all,

I have some commands which when they fail should not stop the workflow itself. But I still want the user to be aware that the command failed.

I tried to achieve this by using -ErrorAction Continue. But it behaves the same way as using Stop there. When using SilentlyContinue or try/catch everything looks fine for the user and I can only catch the error into the command log.

Regards,

Jakob

1 REPLY 1

sinhaa
2,662 Views

Jakob,

1. If a WFA command execution reaches a "failed" state, the workflow execution just stops there.  So there is no way to ignore a WFA command failure and proceed to workflow execution. It could be an seen as an improvement for WFA, but it needs to considered how wide this use case can be. In most cases it not only would be desired but even required to stop execution right there because of dependency.

2. If you want the failure of a cmdlet in a wfa command to be ignored and proceed to execute with the remaining section of the command code and also failing the WFA command in the end, this can be done using write-error.

See the below simple WFA command code:

=======

param (

  [parameter(Mandatory=$true, HelpMessage="Message to print")]

  [string]$Message

)

try

          {

          # Call a non-existent cmdlet which will cause failure

          fake-cmdlet

          }

catch

          {

          Write-Error -Message "This fake-cmdlet is causing the failure"

          }

# execution still proceeds and WFA command execution will fail in the end giving the .

 

Get-WFALogger -INFO -message "Message is : $Message"

======

Write-Error will raise a command execution failure, but will not stop execution right there. So the proceeding section of the command ( Get-WFALogger in our case) will still get executed and the end result of command execution will have raised a command faliure.

This can be used to solve point (1) but in a crude way, if you design your command to do it.

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
Public