Need to get the values in multiple rows, now it is getting separated by space

Hi All,
Need your help.
I am trying to export report on “send on behalf” on 0365 mailboxes, i want the output in multiple rows instead i am getting in singe row.
For eg:
Identity GrantonBehalf

I like to have the output in multiple rows

Identity GrantonBehalf
User1 ABC
User1 XYZ
User1 UVW

The code i use the below

Get-Mailbox -Resultsize Unlimited | Where {$_.GrantSendOnBehalfTo -ne ""} | Select Identity, GrantSendOnBehalfTo |
Export-Csv -Path C:\temp\SendOnBehalf.csv -NoTypeInformation


Instead of the Select-Object you need a loop to iterate over all elements you have in the property GrantSendOnBehalfTo.

Hi Olaf,
I tried the below,
I am getting only the ouput for user and for others i am getting system.object, please help

$GrantSendOn= Get-Mailbox -resultsize unlimited| where {($_.GrantSendOnBehalfTo -ne "")} 

$Out=foreach ($user in $GrantSendOn.GrantSendOnBehalfTo) {

$obj= New-Object System.Object

$obj|Add-Member NoteProperty eMail$GrantSendOn.WindowsEmailAddress

$obj|Add-Member NoteProperty DisplayName $GrantSendOn.DisplayName

$obj|Add-Member NoteProperty User $user

$obj }

$Out| Export-Csv -Path "c:\temp\sendonbehalfpermissions.csv" –NoTypeInformation 


You need a nested loop and you should not use Add-Member

This should do the trick:

$MailboxList = 
    Get-Mailbox -resultsize unlimited | 
        Where-Object -Property GrantSendOnBehalfTo -NE -Value ''  

$Out = 
foreach ($Mailbox in $MailboxList) {
    foreach ($GrantSendOn in $Mailbox.GrantSendOnBehalfTo) {
            eMail       = $GrantSendOn.WindowsEmailAddress
            DisplayName = $GrantSendOn.DisplayName
            User        = $Mailbox

$Out | 
    Export-Csv -Path 'c:\temp\sendonbehalfpermissions.csv' –NoTypeInformation