PowerShell try/catch/finally

前端 未结 2 1134
野性不改
野性不改 2020-12-23 13:38

I recently wrote a PowerShell script that works great - however, I\'d like to now upgrade the script and add some error checking / handling - but I\'ve been stumped at the f

2条回答
  •  盖世英雄少女心
    2020-12-23 14:09

    -ErrorAction Stop is changing things for you. Try adding this and see what you get:

    Catch [System.Management.Automation.ActionPreferenceStopException] {
    "caught a StopExecution Exception" 
    $error[0]
    }
    

提交回复
热议问题