Does Windows Powershell have a Try/Catch or other error handling mechanism?

powershell, scripting, try-catch

Solution

You use a `Trap [exception-type] {}` block before the code you want to handle exceptions for.

Problem

In a script, when a command-let or other executable statement errors out, is there a try/catch type of mechanism to recover from these errors? I haven't run across one in the documentation.

Original source