Capture all errors to a file

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

 
Participant
1 week, 3 days ago.

  • Author
    Posts
  • #182016

    Participant
    Topics: 7
    Replies: 11
    Points: 92
    Rank: Member

    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.

  • #182103

    Participant
    Topics: 1
    Replies: 20
    Points: 65
    Rank: Member

    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.

    example

    $Error | select targetobject,exception | Export-Csv c:\temp\errorfile.csv -NoTypeInformation

You must be logged in to reply to this topic.