Catch block not running my code

I’m looking to run a few things in the Catch block in the event of a failure.

I’m throwing an error based on user response in a dialog box. It is showing everything up to the catch block . However , nothing I add in the catch block runs. Even a simple one-liner to write to the log.

Am I missing a setting here?

Most of Deploy-Application.ps1 is already in a Try-Catch. Maybe it fails before it reaches your Try-Catch?
Maybe you are running into a problem caused by the “Zero-Config MSI Installations” code?

If the catch statement runs like this, the thrown error is shown in the dialog box but my code does not run.

For more info, the function is in the extensions ps1 file. The test-vpnconnectivity does return true.

I’m wondering if it has something to do with the Write-Log ? Even though that works in the Try block just fine.

I can’t upload my other screenshot here (using imgur now).

Here is the scenario where my code is supposed to run first but doesn’t. With those 5 lines from PSADT on the bottom, the dialog box does not run either.

It’s like it doesn’t know what to do with the code I’ve put in, even though it works and has no syntax/formatting errors.

Disregard. It looks like the error was on my part in the Extensions ps1. I made an adjustment to the function and it ran as expected. This can be removed, if needed.

1 Like

I`ll remove it tomorrow in-case you still have issues.

T-A-G