Home > Forum > Actions > Grabbing result or return from powershell

Grabbing result or return from powershell
1

Ok, now that my PS script is running, in this particular instance I need to grab a variable result and assign that value to a form field.

Simply assigning the Form Field = $psvar isn't working.

Is this possible?

MVP

Hi Bo,

I'm not aware of such an option but in most cases I come up with a (crazy) workaround though.

You could log the variable value by using Write-Output. After executing the PS Action you could retrieve it from the log table WFActionExecutions or view WFLogs. I currently don't have access to the system so there may be spelling errors. The problem will be to extract the value from the log. If we could use regular expression it would be easy. Without it this will be tricky.

Edit:
This peaked my interest so I tested it and documented my solution:
https://daniels-notes.de/posts/2021/retrieve-ps-variable-value


Best regards,
Daniel

MVP
In reply to: Bo Jamison

Ok, now I get to learn more about SQL in Webcon hah. I have SQL studio and I've found the corresponding record from the "ps write" in the log view.

Now I just need to get that into Webcon and assign that to a form field. This will work just fine for me once I get that figured out

Thanks!

Hi Bo,

if you need a hint just take a look at the linked post. It contains a full example from the PS Script to assignment. If you haven't done so. :)
Also I have to admit it's always better to work out some things on your own. In addition, I forgot about the AdditionalCompresssedMessage column. So the example will not work in all cases. On the other hand, the logged info will probably always be similar and the return values will either be in one or the other column.



Best regards,
Daniel

In reply to: Daniel Krüger (Cosmo Consult)

Hi Bo,

if you need a hint just take a look at the linked post. It contains a full example from the PS Script to assignment. If you haven't done so. :)
Also I have to admit it's always better to work out some things on your own. In addition, I forgot about the AdditionalCompresssedMessage column. So the example will not work in all cases. On the other hand, the logged info will probably always be similar and the return values will either be in one or the other column.



Best regards,
Daniel

I've got it working, these particular returns are just an 8 character string, at most in another flow it will be a modified email address.

(I have an app to create exchange objects for new users, but it uses a PS that checks if the email already exists, if it does it increments a # on the end of the last name and continues to do that until it finds an unused email. I then need to return that new generated email back to webcon to send to the manager).

I will more than likely have a ton of use cases for grabbing results from PS scripts! It is good to know about the compressed column, that probably would have driven me nuts if I ever needed it hah