There is a try/catch/finally mechanism in powershell: https://docs.microsoft.com/en-us/powershell/module/microsoft...
However, it is quirky to set up and I don't remember the details now, it doesn't handle the errors out of the box for sure.
I would still prefer powershell over bash (or god forbid, cmd) any day.