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
testest test