Difference between revisions of "Exceptions and Error Handling (PowerShell)"

Jump to navigation Jump to search
m
(Initial creation - content from depreciated PowerShell page)
 
 
Line 43: Line 43:
</source>
</source>


== 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>).
== 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

Navigation menu