Can I do this in the Powershell ISE like I can in Visual Studio:
Obviously I am not expecting the same dialogue and I'd hazard a guess I can wrap a try/catch around the part which calls out to the offending (nested) scripts - the bit of stuff I am interested in is nested deep. Id also assume that I can either go and open the existing file and slap a breakpoint in there.
However in the absence of doing that and as a nice convenience I would just like to be able to "break on any exception" because I am lazy.
In PowerShell there are automatic variables
The one you want to adjust is $ErrorActionPreference
$ErrorActionPreference = "stop"
Now when you hit any error within a commands that supports the -ErrorAction switch, the script will stop. It is worth noting that this is a native PowerShell action and you will still need the Try\Catch for any .NET and C# commands
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With