Can a powershell script output information to KACE when run from the Scripting module
Usually, when we run PS scripts using the scripting module, the only output we gety in the output logs is a status message saying that the PS script was successfully launched. Unfortunately, this does not let us know if the script itself ran without issue.
Is there anyway to have a script send back an exit code or status massage to the output logs so that I can tell if the script itself encountered issues?
Any help would be greatly appreciated.
Answers (5)
We use PS and KACE a lot of roll out software, make configuration changes to files, etc. etc.
What I was hoping was that I could throw unexpected exceptions back to the output log during the script run so that when something failed to get the change or software I'd have an idea of why without having to log into machines locally and run the script to see what condition caused it to fail.
I already know how to tell is a change was successful, but I was hoping I could get information saying why it failed, which is more than knowing that it failed.
I can grab exceptions with a try/catch block but I wanted to pass the exception information back up the stack to KACE at the end of the run.
If you had a specific error code, you could specify it with an exit statement, for example if you just wanted to exit with an error code of 1 you would use:
exit 1
This is assuming the K1000 will pay attention to that error code and log it when it runs the script. I have not tested this so I can't answer that part.
You could also, as was already mentioned, write to a log file. You should be able upload the log as the last step in the script, so you wouldn't need a custom inventory for it.