Move from using 'Exit' after a terminating error to adding the -terminateOnError switch to the 'log' function, which will then use Write-Error ... -ErrorAction Stop to exit. The result is that the script exits on errors, but the console does not close.
Move from using 'Exit' after a terminating error to adding the -terminateOnError switch to the 'log' function, which will then use
Write-Error ... -ErrorAction Stop
to exit. The result is that the script exits on errors, but the console does not close.13