Hi, I have the following powershell script and i am trying to catch the error using "ErrorActionPreference='silentlycontinue" followed by try, catch block but cant execute the script. Where can i implement the erroraction command and use try, catch block. Thank you.
Please update your post by formatting the code(use gist.github.com to post the code). Error can happen in multiple areas in the above snippet, Error handling is depended on where you want to handle it.
You can have the whole code snippet in a try catch block. But you have to use -ErrorAction Stop, if you use silentlycontinue, the execution gets continued with out jumping to catch block.