I have a PowerShell script, at its begining I added: $ErrorActionPreference = "Stop"
. It's good, if there is an error the script won't go further.
Fact is that when an error occurs, the script stop and exit itself and so, I can not see the error.
The best option is to crate a logfile that will write EVERYTHING that was in the PowerShell terminal, including succesful lines. If not, at least make the terminal keep opened even if an error occurs, but stop the script.
try{} catch{}
– T-Me