2,187
edits
(Initial creation - content from depreciated PowerShell page) |
m (→Basic Error Handler: Typo fix) |
||
Line 43: | Line 43: | ||
</source> | </source> | ||
== Try...Catch == | == Try...Catch == | ||
Used to catch an exception in a script block where an exception may be likely. Stops the exception being shown on the console and gives you a chance to do something about it (as long as you've set <code>$ErrorActionPreference</code> to Stop or used <code>-ErrorAction:Stop</code>). | |||
<source lang="powershell"> | <source lang="powershell"> | ||
try | try |