Hello.
I'm executing a script on a remote PowerShell host, and I want to be able to act upon either the exit code or some other output text within a string variable to do something like log, or fail the workflow within vRO.
The example being that if i attempt to run a native windows command (e.g. dnscmd.exe) within my PowerShell script that returns "Access Denied" or similar, as the PowerShell script still completes successfully, so does the vRO workflow.
How can I forcibly fail the workflow when certain output criteria is met?
Thanks,
Dan
I knwo this is quite old, but to anyone else looking, this helped me sort out a return code I could use. I had to return value from Powershell, extract them using this link and then compare the values in the workflow. If they matched error messages, I simple threww and error in the workflow. Granted, you ahve to know what to check for...
One approach could be within your external script is within the end block use a switch statement to evaluate the exit code ($LASTEXITCODE) to select the appropriate action.
For Example:
End{
Switch ($LASTEXITCODE){
'0' {Write-Host 'success message'},
'1' {throw 'error message'} ,
'81' {Write-Host 'custom message'}
} # Switch ($LASTEXITCODE)
} # End
Status of the last command - https://www.safaribooksonline.com/library/view/windows-powershell-cookbook/9780596528492/ch01s11.htm...