#Requires -Version 2
# Show-TryCatchFinally.ps1
# Demonstrates try/catch/finally in V2
# First, try something that will work
Try {
$I=1
}
Catch {"Caught a problem in try 1"
}
Finally {
"All done with 1st try"
}
# Now try something that fails
$one=1
#$zero=0
Try { $one/$zero}
Catch {"Caught a problem in try 2"}
Finally {"All done with second try"}
PS C:\foo> . 'C:\Users\tfl\AppData\Local\Temp\Untitled14.ps1'
All done with 1st try
Caught a problem in try 2
All done with second try


0 comments:
Post a Comment