Error Handling Background Jobs

Welcome Forums General PowerShell Q&A Error Handling Background Jobs

This topic contains 1 reply, has 2 voices, and was last updated by

1 year, 9 months ago.

  • Author
  • #70429

    Points: 0
    Rank: Member

    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

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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.

The topic ‘Error Handling Background Jobs’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort