###--------------------------------------------- ### A try/catch/finally example. ###--------------------------------------------- try { Write-Host "Try this." $Result = 1/$Zero } catch [System.DivideByZeroException] { Write-Host "Caught divid by zero exception." } catch [System.SystemException] { # This catch will catch every thing else. Write-Host "Caught base exception." } finally { Write-Host "Finally this." }
Sunday, February 19, 2012
PowerShell: Try, Catch, and Finally
This is the example I like to refer to for my PowerShell try/catch/finally blocks.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment