Google News
logo
PowerShell - Interview Questions
What is Try, Catch, and finally in PowerShell?
Try : It is a part of a script where we want the PowerShell to monitor the errors. If an error occurs in this block, the automatic variable $Error stores the error. And then, the PowerShell searches the Catch block to handle the error.
 
Catch : In a PowerShell script, it is a part which handles the errors generated by the Try block.
 
Finally : In a PowerShell script, it is a part which releases the resource that no longer needed by a script.
Advertisement