How to capture the exception raised in the scriptblock of start-job?

前端 未结 4 557
说谎
说谎 2020-12-29 23:08

I have the following script,

$createZip = {
    Param ([String]$source, [String]$zipfile)
    Process { 
        echo \"zip: $source`n     --> $zipfile\"
         


        
4条回答
  •  误落风尘
    2020-12-29 23:20

    This should be a comment really, but I don't have the reputation to leave comments.

    My answer is that you should use Andy Arismendi's answer, but also output $job.ChildJobs[0].Error

    As $job.ChildJobs[0].JobStateInfo.Reason.Message isn't always useful.

提交回复
热议问题