NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Active IQ Unified Manager Discussions

How to cause a WFA command to report failure and stop workflow execution?

korns
4,528 Views

I'm building a PowerShell command that uses dataontap get-naQuotaReport() cmdlet. Based on a number of factors there is no way to completely validate the volume and qtree names in advance so I need the command to be executed and to either work (if /vol/volume/qtree exists) or fail if they don't (i.e.; get-naquotareport returns nothing). I spent awhile trying to catch an error condition with try/catch but it doesn't seem to work and other discussions here indicate it won't work anyway. So the only way I find to determine failure is to look for the case where get-naQutaReport returns nothing (or the [string]$qrObject is ""). I can detect that condition properly and log it with Get-WFA-Logger but how do I make the command return an error status to WFA, go red and stop further workflow execution? I'm trying 'exit 1' which doesn't seem to do it and have no other ideas.

---- snippet ----

    $qtreePath = "/vol/" + $VolumeName + "/" + $QtreeName

#

# Determine Current DiskUsed & DiskLimit

#

    $qrObject = (Get-NaQuotaReport -Path $QtreePath)

    if([string]$qrObject -eq "")

    {

        Get-WFALogger -Error -message $("Get-NaQuotaReport cmdlet failed looking up " + $qtreePath)

        exit 1;

    }

    $curDiskUsed = [int]$qrObject.DiskUsed

    $curDiskLimit = [int]$qrObject.DiskLimit

1 ACCEPTED SOLUTION

karale
4,528 Views

Hi korns,

instead of exit, can you try

throw "something is wrong"

View solution in original post

2 REPLIES 2

karale
4,529 Views

Hi korns,

instead of exit, can you try

throw "something is wrong"

korns
4,528 Views

Thanks, that does it.

Public