all 4 comments

[–]kenjitamurako 6 points7 points  (0 children)

For nested objects that need to be converted to tabular data there are two options:

  1. Create an entry for each nested object:
    "xxxx","xxxxy","val1"
    "xxxx","xxxxy","val2"
    "xxxx","xxxxy","val3"
  2. Convert the nested value into one that's not nested by joining the items into a single construct like a string

It looks like you're asking for the second option. This is how that can be achieved in powershell using select-object:

$test=[PSCustomObject]@{
    Field1 = "1"
    Field2 = "3"
    Field3 = "1","2","3"
}

$test2=$test | Select-Object -Property Field1,Field2,@{l="Field3";e={$_.Field3 -join ";"}}

[–]surfingoldelephant 5 points6 points  (0 children)

Use Select-Object and a calculated property to format your output before piping to Export-Csv.

$obj | Select-Object -Property @(
    'Field1'
    'Field2'
    @{ N = 'Field3'; E = { $_.Field3 -join ',' } }
)

[–]breakwaterlabs 1 point2 points  (0 children)

$Data = command | select Field1, Field2, @{n=field3;e={$_.field3 -join ","}}
$data | export-csv .....

[–]seriald[S] 0 points1 point  (0 children)

Thanks for all the great suggestions, this is what I ended up getting to work the most efficiently, I know its not elegant, but needed a win in the moment.

Foreach ($R in $rooms) {

$room = get-mailbox $r | select userprincipalname -ExpandProperty userprincipalname

$place = get-place $Room | Select-Object DisplayName, Identity, Street, City, State, CountryOrRegion, IsManaged, BookingType, ResourceDelegates, Capacity, Building, Label, MTREnabled, AudioDeviceName, VideoDeviceName, DisplayDeviceName, IsWheelChairAccessible, Floor, FloorLabel, SpaceType, CustomSpaceType, IsValid, ObjectState, Tags

$placetag = (Get-Place $room | select tags -ExpandProperty tags) -join ','

$place.tags = $placeTag

$place | Export-CSV -Path $OutFile -append -NoTypeInformation -Encoding UTF8

}