Welcome › Forums › General PowerShell Q&A › Capture all errors to a file
This topic contains 1 reply, has 2 voices, and was last updated by
Is there a way to capture all the errors to a csv file with complete information? I need it to a file because these are task scheduled scripts.
Any ideas? My main goal is to get the complete error data.
The $Error variable captures all occurring errors. You could just pipe it to export-csv, or select just the properties you want to have in your csv.
$Error | select targetobject,exception | Export-Csv c:\temp\errorfile.csv -NoTypeInformation
You must be logged in to reply to this topic.