Get execution status after running PS1 script?

Get execution status after running PS1 script?

Is there a way to get informative remarks after deploying a ps1 script to an endpoint?

For a simple example:

I have the following script which is intended to uninstall a software by referencing its MSI package code:
msiexec /x {D834B61E-F774-4EDD-B776-EFB6D60E0AA7} /quiet /norestart

If I deploy this as a bat file through Endpoint Central, I might get a status "Retry in progress" with the remarks "Script fails with error : This action is only valid for products that are currently installed.".

If I deploy this as a ps1 file through Endpoint Central, on the exact same device which should also result in an error, I get a status "Succeeded" with the remarks "script executed Successfully".

Are there any callbacks which I can add to the ps1 script that can be used in conjunction with some custom logging and error handling?  I can do some logic to log to a txt file, but it would be better to see directly in Endpoint Central if the script executed successfully or not.  Especially when deploying to a large group of devices.

PS - My actual script is a bit longer than the above example and is why I am using PowerShell to achieve a specific goal.

                New to ADSelfService Plus?