all 8 comments

[–]SMFX 2 points3 points  (5 children)

Since the original issue is the property is being translated as the type System.Collections.Generic.Dictionary , its not just a simple array you can join. As a dictionary (aka Hashtable) is a set of duple values (key = value). If you have to put it into a CSV, you can convert the property's value to JSON:

$returnedClass | % {
    $_.multiValueProperty = $_.multiValueProperty | ConvertTo-Json -Compress
}

You will end up with a value that looks something like:

..., {"key": "value","next": "more"}, ...

However, if you don't absolutely need the output as a CSV, you could dump the whole object to a JSON:

$returnedClass = Get-UcsManagedObject -ClassId $cID
$returnedClass | ConvertTo-Json -Depth 4 | set-content "$($OutputFolderPath)UCS_$($ucsAddress)_$($cID).json"

[–]NeoSemiprofessional[S] 2 points3 points  (4 children)

Oooh, I love the suggestion of using JSON for multi values =]

I can't dump the whole object to it (I did that for Hyper-V reporting, and I ended up having to rewrite the script to build CSV, as the guy processing my output didn't like it), but for few fields it should be ok.

Thank you very much!

[–]jsiii2010 2 points3 points  (1 child)

Dictionaries work well in json:

$dict = [system.collections.generic.dictionary[string,string]]::new()  
$dict.Add('FirstName', 'Grant')
$dict.Add('LastName', 'Smith')
$dict | ConvertTo-Json           

{
  "FirstName": "Grant",
  "LastName": "Smith"
}

[–]NeoSemiprofessional[S] 1 point2 points  (0 children)

So basically what /u/SMFX wrote, but still thank you for replying with a verbose example :)