export-csv | import-csv

Jamie Woodford 21 Reputation points
2022-02-08T15:06:57.32+00:00

simple question i want to create a .csv file and than display it as a table in one command i'm entering

get-eventlog -logname application -before 14:51:56 |sort instanceid | select-object instanceid, message |export-csv -path c:\test\appevt.csv | import-csv -path c:\test\appevt.csv | format-table

I get no error message but i also do now get the table i want please help

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,462 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 45,906 Reputation points
    2022-02-08T15:24:28.487+00:00

    Export-CSV writes to a file and doesn't put anything into the pipeline. A $null value isn't passed through pipeline, so your Export-CSV is never run.

    get-eventlog -logname application -before 14:51:56 |sort instanceid | 
        select-object instanceid, message |
            export-csv -path c:\test\appevt.csv
    import-csv -path c:\test\appevt.csv | format-table
    
    0 comments No comments