[PS] Write powershell errors to a text file

Method 1: Try, Catch, Finally

Try: Try to execute a command
Catch: Catches any errors, triggers only for Terminating Errors, so you may need to set a ErrorAction -Stop (EA) for errors that are not terminating.
Finally: Runs regardless if a error occurs.

Method 2: Output error directly to error log 

Method 3: Customize a out-file to a error log

 

epic
Author Details
Contributer and Author Enterprise Communications Engineer Hi Epic

testest test 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments