Expanding arrays when exporting to CSV

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of figueroa2david figueroa2david 3 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #4222
    Profile photo of figueroa2david
    figueroa2david
    Participant

    I'm running some Citrix powershell commands that output arrays of objects.  They look right on the screen, but when I output to CSV, it shows the object type.  I've looked around, and I haven't found a good answer on how to expand this — especially because some of the properties are not arrays, and some are.

    `Get-XAApplication | foreach {Get-XAApplicationReport -BrowserName $_.Browsername} | Select-Object DisplayName,Accounts,ServerNames`

    The output comes out like this on the screen:

    `
    DisplayName                            Accounts                            ServerNames
    ———–                             ——–                                ———–
    Notepad                                 {Domain\Domain Users, Domain\Domain Ad... {Server1, Server2, Server3...
    Word 2010                               {Domain\Domain Users, SWRCU\Domain Ad... {Server1, Server2, Server3...`

    The Accounts & Servernames are arrays.

    I am trying to do this:

    `Get-XAApplication | foreach {Get-XAApplicationReport -BrowserName $_.Browsername} | Select-Object DisplayName,Accounts,ServerNames | export-csv -path c:\temp\AppReport.csv`

    I get this in the CSV file:

    `#TYPE Selected.Citrix.XenApp.Commands.XAApplicationReport
    "DisplayName","Accounts","ServerNames"
    "Notepad","Citrix.XenApp.Commands.XAAccount[]","System.String[]"
    "Word 2010","Citrix.XenApp.Commands.XAAccount[]","System.String[]"`

    I'm primarily concerned with the correct technique to expand those arrays in the CSV file.

    Thank you for any help.

    David F.

    #4255
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Er, no. CSV is a flat format – it just isn't designed for a hierarchy. You'd have to do something manual, so expanding out the collections into whatever simple string you wanted, and then send it to CSV. XML is better designed for what you're doing.

    #4532
    Profile photo of figueroa2david
    figueroa2david
    Participant

    And that's the part I want to do :-)  I want to somehow expand those objects manually to get them added to the text file.  I've got other utilities written to take advantage of the flat data (they are written in Winbatch).  The end-goal is to get them into a table format.

    I can start tinkering with the XML commands.

    Thanks,

     

    David F.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.