# Expanding arrays when exporting to CSV

**URL:** <https://forums.powershell.org/t/expanding-arrays-when-exporting-to-csv/31>\
**Category:** PowerShell Help\
**Created:** [May 7, 2013, 6:51am UTC](https://forums.powershell.org/t/expanding-arrays-when-exporting-to-csv/31 "2013-05-07T06:51:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![figueroa2david](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/figueroa2david/32/485_2.png) [@figueroa2david](https://forums.powershell.org/u/figueroa2david)\
**Post date:** [May 7, 2013, 6:51am UTC](https://forums.powershell.org/t/expanding-arrays-when-exporting-to-csv/31/1 "2013-05-07T06:51:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [May 7, 2013, 7:46am UTC](https://forums.powershell.org/t/expanding-arrays-when-exporting-to-csv/31/2 "2013-05-07T07:46:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![figueroa2david](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/figueroa2david/32/485_2.png) [@figueroa2david](https://forums.powershell.org/u/figueroa2david)\
**Post date:** [May 10, 2013, 2:00am UTC](https://forums.powershell.org/t/expanding-arrays-when-exporting-to-csv/31/3 "2013-05-10T02:00:11Z")

</div>

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,

&nbsp;

David F.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:57pm UTC](https://forums.powershell.org/t/expanding-arrays-when-exporting-to-csv/31/4 "2024-05-16T20:57:48Z")

</div>


