When waiting for the job with Wait-Job (like suggested in this answer) the exception returns correctly, but I need a non-blocking approach. If you use Start-Job instead of Start-ThreadJob, the exception doesn't return in the event-based approach, too.
Receive-Job
yields no output onStart-ThreadJob
- orStart-Job
-jobs, when listening toCompleted
orFailed
JobState changes withRegister-ObjectEvent
.$PSVersionTable dump:
Steps to reproduce the issue:
When waiting for the job with
Wait-Job
(like suggested in this answer) the exception returns correctly, but I need a non-blocking approach. If you useStart-Job
instead ofStart-ThreadJob
, the exception doesn't return in the event-based approach, too.