Error Handling Background Jobs

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 1 year ago.

  • Author
  • #70429

    Jason Robinson

    What is the best way to handle errors when using background jobs? From what I am experiencing it seems to be limited in the amount of information I can get from Receive-Job. Is there anyway to get the error exception type of the error that occurred inside the job? I normally use a try/catch construct for most of my error handling, but I am not sure if that is really useful inside the scriptblock of a job. Sorry for so many questions, just really looking for some feedback and guidance on what others use and have been successful with.

    Thank you for any assistance!

  • #70474

    Don Jones

    Yeah, it's pretty limited. And yes, the best way would be to implement a Try/Catch – I usually put my commands into a script, and push that to the remote machine, versus using a script block. That way I can have as much structured error handling as I want.

You must be logged in to reply to this topic.