3

I have a pscustomobject whose NoteProperty "Members" is populated with values within a loop.

$results.Members += $currentGroupMember.Title

When I do "Export-Csv" all values within "Members" are displayed in one Excel cell. Is it possible to have it start a new line for each value?

I tried to convert it like this:

$results.Members = (@($results.Members) | Out-String).Trim()

But it doesn't change anything.

1 Answer 1

0

this is how i am doing to get the results. try the below code ( please change your for loop logic as i just get the idea from your code.

$results = @()

foreach($currentGroupMember in $currentGroupMembers)
{
$output = New-Object PSObject
$output | Add-Member NoteProperty -name "Memebers" -Value $currentGroupMember.Title
$results += $output
}
$results | Export-Csv C:\result.csv -NoTypeInformation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.