Last active
August 29, 2015 14:08
-
-
Save lantrix/1e34ed4a1be1f2507dff to your computer and use it in GitHub Desktop.
Powershell Throw, Catch, Finally example passing Throw Text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $throwError = "" | |
| try { | |
| throw "exception has occured! Failure text" | |
| } catch { | |
| #Catch throw test | |
| $throwError = $_ | |
| } finally { | |
| if ([bool]$throwError) { | |
| Write-Host "$throwError" | |
| } else { | |
| Write-Host "Finished Successfully" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment