& {
trap { throw $_ }
&$Finally
}
}
使用示例:
Try {
echo " ::Do some work..."
echo " ::Try divide by zero: $(0/0)"
} -Catch {
echo " ::Cannot handle the error (will rethrow): $_"
#throw $_
} -Finally {
echo " ::Cleanup resources..."
}
PowerShell: Try...Catch...Finally 实现方法
原文:http://www.jb51.net/article/42615.htm