February 2019
Intermediate to advanced
626 pages
15h 51m
English
One try-catch-finally statement can be nested beneath another. This is most appropriate when a different approach is required by a smaller section of code.
A script which performs setup actions, then works on a number of objects in a loop, is a good example a script that might benefit from more than one try-catch statement. The script should terminate cleanly if something goes wrong during setup, but it might only notify you if an error occurs within the loop.
The following functions can be used as a working example of such a script. The setup actions might include connecting to a management server of some kind:
function Connect-Server {}
Once the connection is established, a set of objects might be retrieved:
Read now
Unlock full access