PsCustomObject into CSV

Welcome Forums General PowerShell Q&A PsCustomObject into CSV

This topic contains 2 replies, has 2 voices, and was last updated by

YCE
 
Participant
2 years, 5 months ago.

  • Author
    Posts
  • #44920
    YCE

    Participant
    Points: 12
    Rank: Member

    I have a number of server scan results in a custom object properties like some file paths, local groups. Problem is when I try to export to csv some note properties e.g. file paths get cut and my local groups get only first line in the csv. As an example I have a Custom Object called $report with note properties scheduled_task_action C:\Program Files\ABC\test.exe C:\Program Files\ABC\test.xml where after exporting to csv I see only C:\Program Files\A
    or in my local_admins list property :
    adminsitartor;
    domain\user1;
    domain\user2,
    ...
    I only get administrator. All the note properties are strings. I export with
    $report | select scheduled_task_action, local_admins | Export-CSV .\test.csv -force -encoding UTF8 -NoTypeInformation
    How can this be fixed so the whole properties show up when I open the csv in Execl?

  • #44924

    Member
    Points: 0
    Rank: Member

    Depends on what's in the objects you're exporting to a CSV. Also, in Excel, you may need to change your column height / row width in order to see all of the information that's available in each cell.

  • #44926
    YCE

    Participant
    Points: 12
    Rank: Member

    You're right. I incorrectly assumed that export-csv will add comas where needed yet looking at the resulting csv in notepad it seems it's not the case so need to sort out my formatting.
    I noticed that for some reason in the resulting csv I get end of line followed by "," in the line below which messes up the csv
    e.g.
    "scheduled_task_action","c:\test.exe c:\test.xml
    ","scheduled_task_name"
    ","....
    what coule be the reason for that?

The topic ‘PsCustomObject into CSV’ is closed to new replies.