Difference between revisions of "Power Shell"

Jump to navigation Jump to search
522 bytes added ,  08:25, 23 December 2009
m
m (Added "Exceptions and Error Handling")
Line 204: Line 204:


== Exceptions and Error Handling ==
== Exceptions and Error Handling ==
* http://huddledmasses.org/trap-exception-in-powershell/
To control how a script behaves as a result of an exception, modify the <code> $ErrorActionPreference </code> variable, if required.
{|cellpadding="1" cellspacing="0" border="1"
|- style="background-color:#bbddff;"
! Value            !! Effect
|-
| Continue          || [Default] Outputs error, but keeps processing
|-
| SilentlyContinue  || No output and it keeps going
|-
| Inquire          || Prompt user for action
|-
| Stop              || Outputs error and halts processing
|}


* http://huddledmasses.org/trap-exception-in-powershell/
=== Basic Error Catcher ===


If you know where the error is likely to occur, then just place an error catcher immediately after it...
If you know where the error is likely to occur, then just place an error catcher immediately after it...
Line 212: Line 229:
     # Handle error here
     # Handle error here
   }
   }
 
</pre>


[[Category:PowerShell]]
[[Category:PowerShell]]
[[Category:WMI]]
[[Category:WMI]]
[[Category:MySQL]]
[[Category:MySQL]]

Navigation menu