Powershell Error Exceptions and Exception Handling

Exception Handling
PowerShell supports try/catch/finally,
which should feel familiar to java, .NET developers. Initially PowerShell v1 introduced the trap statement, which still works, but I prefer try/catch/finally. PowerShell trap statement to trap the error and stop execution of the script using the break statement. trap {"Exception: $($error[0])"; break} 1/0 "done"

Output: Exception: Attempted to divide by zero. Attempted to divide by zero. At line:2 char:1 + 1/0 + ~~~ + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : RuntimeException