locked
Export-csv results issue for multiple smtp addresses RRS feed

  • Question

  • I have the following script that works but puts all the EmailAddresses in one cell. I am trying to get it so each address is in it own cell/column 

    Get-Mailbox -OrganizationalUnit "zDisabledAccounts" | Select Name, @{Name=’EmailAddresses’;Expression={[string]::join(";", ($_.EmailAddresses))}} | Export-CSV C:\Log\Address.csv -append


    Stonecold31666

    Monday, February 5, 2018 5:31 PM

All replies

  • have you try select emailaddresses -expandproperty

    Chris

    Monday, February 5, 2018 5:44 PM
  • Didn't you try this.

    Get-Mailbox -OrganizationalUnit "zDisabledAccounts" | Select Name,EmailAddresses | Export-CSV C:\Log\Address.csv -NoTypeInformation


    Regards kvprasoon

    Monday, February 5, 2018 5:57 PM
  • i did and this was the result for the addresses

    EmailAddresses
    Microsoft.Exchange.Data.ProxyAddressCollection
    Microsoft.Exchange.Data.ProxyAddressCollection
    Microsoft.Exchange.Data.ProxyAddressCollection
    Microsoft.Exchange.Data.ProxyAddressCollection


    Stonecold31666

    Monday, February 5, 2018 6:10 PM
  • ok, not well versed with Exchange cmdlets,

    Try without using -join,

    Get-Mailbox -OrganizationalUnit "zDisabledAccounts" | Select Name, @{Name=’EmailAddresses’;Expression={$_.EmailAddresses}} | Export-CSV C:\Log\Address.csv 


    Regards kvprasoon

    Monday, February 5, 2018 6:19 PM
  • You have to enumerate the mailboxes the enumerate the addresses while creating a custom object.


    \_(ツ)_/

    Monday, February 5, 2018 6:23 PM
  • i am closer with the following. it puts primary in its own column the list all in the 3rd column. 

    Get-Recipient -Resultsize unlimited | Select Name,PrimarySmtpAddress, @{L="EmailAddresses";E={$_.EmailAddresses | ? {$_.PrefixString -ceq "smtp"} | % {$_.SmtpAddress}}} | Export-Csv c:\log\ALLemail.csv -NoTypeInformation -append


    Stonecold31666

    Monday, February 5, 2018 6:25 PM