How do I exit from a try-catch block in PowerShell?
13:13 03 Nov 2012

I want to exit from inside a try block:

function myfunc
{
   try {
      # Some things
      if(condition) { 'I want to go to the end of the function' }
      # Some other things
   }
   catch {
      'Whoop!'
   }

   # Other statements here
   return $whatever
}

I tested with a break, but this doesn't work. It breaks the upper loop if any calling code is inside a loop.

powershell try-catch