Get-Event Log Garbled Output

This topic contains 2 replies, has 2 voices, and was last updated by  Windows LiveUser44 3 years, 6 months ago.

  • Author
    Posts
  • #12844

    Windows LiveUser44
    Participant

    Hi:

    Running PS4. When I run the following command, the CSV file looks like gibberish. The command does not give any errors but I do remember a scripting guy video I watched saying something about to the "headers?" I may be wrong. However the command displays on the screen as expected when I remove the Export-csv.

    This is the command: Get-EventLog -ComputerName Hades -LogName Application -Newest 10 | where EventID -ne 1003, 45, 7 |Format-List -GroupBy source |Export-Csv 1.csv

    This is the result:

    #TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
    ClassId2e4f51ef21dd47e99d3c952918aff9cd pageHeaderEntry pageFooterEntry autosizeInfo shapeInfo groupingEntry
    033ecb2bc07a4d43b5ef94ed5a35d280 Microsoft.PowerShell.Commands.Internal.Format.ListViewHeaderInfo
    9e210fe47d09416682b841769c78b8a3 Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry
    27c87ef9bbda4f709f6b4002fa4af63c
    4ec4f0187cb04f4cb6973460dfe252df
    9e210fe47d09416682b841769c78b8a3 Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    4ec4f0187cb04f4cb6973460dfe252df
    9e210fe47d09416682b841769c78b8a3 Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry
    27c87ef9bbda4f709f6b4002fa4af63c
    4ec4f0187cb04f4cb6973460dfe252df
    9e210fe47d09416682b841769c78b8a3 Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    4ec4f0187cb04f4cb6973460dfe252df
    cf522b78d86c486691226b40aa69e95c

    See attached jpg. Thanks in advance.

  • #12847

    Dave Wyatt
    Moderator

    The problem is that you've got Format-List in your pipeline. The Format-* commands must only ever be piped to one of the default Out-* commands (Out-String, Out-Host, Out-Default, etc). Any other cmdlet is not going to handle the formatting objects properly.

    In this case, { Get-EventLog -ComputerName Hades -LogName Application -Newest 10 | where EventID -ne 1003, 45, 7 | Export-Csv 1.csv } may do the trick, though because CSV files are completely flat, you may not get all of the data you want. If you have other questions about how the output looks after getting rid of Format-List, let us know.

  • #12848

    Windows LiveUser44
    Participant

    Thanks Dave. That did it. 🙂

You must be logged in to reply to this topic.