Export-CSV RRS feed

  • Question

  • I can't get the export-csv work

    Admin 1.0.1 testone
     $file|Export-Csv -NoTypeInformation -Path k.csv

    k.csv is showing properties of the file instead of output from $file

     Get-Process |Export-Csv -NoType ps.csv <-- This one is working

    Thanks in advance

    • Moved by Bill_Stewart Monday, July 30, 2018 1:40 PM Abandoned
    Thursday, June 7, 2018 1:30 AM

All replies

  • What is "$file".  Is it a file object?  How did you create it?

    To get file contents you need to use "Get-Content"

    File contents will be text and cannot be output to a CSV.

    I recommend learning PowerShell before attempting to use it.  You clearly do not understand how it works.  You cannot learn PowerShell by guessing. 


    Thursday, June 7, 2018 2:25 AM
  • PS C:\temp> type test
    Admin 1.0.1 test
    PS C:\temp> $file=(gc test)
    PS C:\temp> $file
    Admin 1.0.1 test
    PS C:\temp> $file.gettype()

    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     True     String                                   System.Object

    Thursday, June 7, 2018 12:15 PM