SOLVED

expanding a System.Collections.Generic.List[string]

Brass Contributor

Im using the following code to add properties to an object

 

$ten = Get-MsolCompanyInformation -TenantId $tenantItem
$objTenantData = New-Object -TypeName system.object
$objTenantData | Add-Member -Type NoteProperty -Name AuthorizedServiceInstances -value $ten.AuthorizedServiceInstances

The problem is that some of the properties of the MsolCompanyInformation are lists (System.Collections.Generic.List[string])

 

I need help to get the contents of that list into  $objTenantData as text.

 

Can you help me?

 

 

/Mats

 

 

 

 

1 Reply
best response confirmed by Mats Warnolf (Brass Contributor)
Solution
I am assuming that the Add-member line is just one of many you want to add to the $objTennantData object and that you want the string array added as a single value (let me know if these assumptions are incorrect)

If so, for any properties that are arrays use the following:
$objTenantData | Add-Member -Type NoteProperty -Name AuthorizedServiceInstances -value ($ten.AuthorizedServiceInstances -join ' ')

Note: You can put other symbols in the ' ' after join and that is what will separate each value in the new string.
1 best response

Accepted Solutions
best response confirmed by Mats Warnolf (Brass Contributor)
Solution
I am assuming that the Add-member line is just one of many you want to add to the $objTennantData object and that you want the string array added as a single value (let me know if these assumptions are incorrect)

If so, for any properties that are arrays use the following:
$objTenantData | Add-Member -Type NoteProperty -Name AuthorizedServiceInstances -value ($ten.AuthorizedServiceInstances -join ' ')

Note: You can put other symbols in the ' ' after join and that is what will separate each value in the new string.

View solution in original post