How can I set in a PowerShell script that all the actions have the property ErrorAction set to Stop?
P.S.: Powershell 2.0
Set the $ErrorActionPreference for the script to stop:
$ErrorActionPreference = "Stop"
edit: As ivan-mirchev pointed out, of course this change is not permanet and only active in the runspace where the code is executed. When you open a new Powershell session it will have the default value of $ErrorAction = 'Continue'
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