Practically, catching and throwing the same error shouldn't be any different to not catching it in the first place (as in scenario 2), however I've included it here for completeness.
Results
Scenario
Runbook status
Error logged
Requirements
1. Default behaviour
Completed
Yes
❌ ✔️
2. Stop on error
Failed
None found
✔️ ❌
3. Catch and log
Failed
None found
✔️ ❌
4. Catch and throw
Failed
None found
✔️ ❌
Is it possible to set up a PowerShell runbook that will satisfy both of my requirements?
I'm using a PowerShell 5.1 runbook running on 'Azure' in the Australia East region.
I have two requirements for error handling in a PowerShell runbook:
I've tried several minimal scripts while attempting to meet these requirements, however none satisfy both together.
Default behaviour:
Stop on error:
Catch and explicitly log error:
Catch and explicitly throw error:
Practically, catching and throwing the same error shouldn't be any different to not catching it in the first place (as in scenario 2), however I've included it here for completeness.
Results
Is it possible to set up a PowerShell runbook that will satisfy both of my requirements?
I'm using a PowerShell 5.1 runbook running on 'Azure' in the Australia East region.