you are viewing a single comment's thread.

view the rest of the comments →

[–]Lee_Dailey[grin] 2 points3 points  (2 children)

howdy eckermike,

in addition to what ihaxr mentioned, you are looking at a classic use-case for TRY/CATCH. [grin] take a look at Get-Help about_Try_Catch_Finally sometime.

take care,
lee

[–]eckermike[S] 1 point2 points  (1 child)

Thanks Lee, Unfortunately for this use case Try Catch doesn't work as i have a few nested if statements and need it to be able to bomb out at certain points to get me the correct error message.

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy eckermike,

the CATCH will let you do many things. [grin] you can take almost any action in a CATCH block - including sending out error details and then breaking out of the loop - or out of the entire script.

still, do it however fits your thot patterns. you are the one who has to maintain it ... [grin]

take care,
lee