Posted On April 2, 2019

Explain Try and Catch Block

kimconnect 0 comments
blog.KimConnect.com >> Codes >> Explain Try and Catch Block
try {
Execute function X;
Execute function Y;
}
catch
{
Execute this when any function fails: X or Y;
}
finally
{
Execute function Z regardless whether X or Y fails;
}

# Note: if a “break,” “continue,” “return,” or “exit” command is triggered inside this block, the block will immediately get out of scope.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Use Regex to Select IPv4 Patterns

# This example shows how to obtain ip address of the $env:logonserver$logonServerIP=nltest /DSGETDC:$regexIP = [regex]…

User Account Group Membership Copy

This is the quick snippet to be executed in the context of a Domain Administrator:…

PowerShell: Function to Wait for Service to Be Back Online (After Server Reboots)

Function waitForService{ $testSucceeded=(Test-NetConnection $server -port $port).TcpTestSucceeded $null=Set-PSBreakpoint -Variable rightNow -Mode Read -Action { $global:testSucceeded =…