Export-CSV only exports the string length
Hi friends. I am trying to get a list of all the e-mails I have on the server, even proxy accounts, each one in a separated row. I tried to get this with this command get-mailbox | foreach-Object -process {$_.emailaddresses} | export-csv 'c:\file.csv' -notypeinformation but with this I only get the string lengths on the .csv file. I have also tried this other method, but have the same problem. get-mailbox | select -expandproperty emailaddresses | export-csv 'c:\file.csv' -notypeinformation I found it wierd, since when I only display on the screen, without writing the export-csv part, I get exactly what I want. Does anybody know how to solve this? Thanks, Vladimir
June 26th, 2010 6:02pm

On Sat, 26 Jun 2010 15:02:55 +0000, Vladimir_Magalhaes wrote: > > >Hi friends. > > > >I am trying to get a list of all the e-mails I have on the server, even proxy accounts, each one in a separated row. > >I tried to get this with this command > > > >get-mailbox | foreach-Object -process {$_.emailaddresses} | export-csv 'c:\file.csv' -notypeinformation > > > >but with this I only get the string lengths on the .csv file. The 'emailaddresses' property is an array of objects (SmtpProxyAddress, CustomProxyAddress, X400ProxyAddress, InvalidProxyAddress), and each of them have several properties of their own (SmtpAddress, AddressString, ProxyAddressString, Prefix, IsPrimaryAddress, PrefixString). So, one way to get a list of all the addresses, with their address types, would be: get-mailbox | foreach-Object {foreach ($a in $_.emailaddresses){write $a.proxyaddressstring}} If you want only SMTP addresses you could use this: get-mailbox | foreach-Object {foreach ($a in $_.emailaddresses){ if ($a.prefixstring -eq 'smtp') {write $a.proxyaddressstring}}} Or, if you don't want to know if the address is a primary (the address type would be in upper-case) or secondary (the address type would be in lower-case), you could use: get-mailbox | foreach-Object {foreach ($a in $_.emailaddresses){ if ($a.prefixstring -eq 'smtp') {write $a.addressstring}}} > >I have also tried this other method, but have the same problem. > > > >get-mailbox | select -expandproperty emailaddresses | export-csv 'c:\file.csv' -notypeinformation > > > >I found it wierd, since when I only display on the screen, without writing the export-csv part, I get exactly what I want. > > > >Does anybody know how to solve this? > > > >Thanks, > >Vladimir --- Rich Matheisen MCSE+I, Exchange MVP --- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
June 26th, 2010 9:50pm

Hi, Try this one-liner: Get-Mailbox -server MailboxServerName | Select DisplayName, @{Name=’EmailAddresses’;Expression={[string]::join(";", ($_.EmailAddresses))}} | Export-CSV C:\\EmailIDs.csv -notypeinformation Regards, Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
June 26th, 2010 11:36pm

get-mailbox | foreach-Object -process {$_.emailaddresses} | export-csv 'c:\file.csv' -notypeinformation get-mailbox | select -expandproperty emailaddresses | export-csv 'c:\file.csv' -notypeinformation I found it wierd, since when I only display on the screen, without writing the export-csv part, I get exactly what I want. Hi Vladimir, Do you mean if you don't add Export-Csv in these two cmdlets, the results on the display is just you want? Will it be meet you needs if you export the results to a txt file? get-mailbox | foreach-Object -process {$_.emailaddresses} >c:\file.txtFrank Wang
Free Windows Admin Tool Kit Click here and download it now
June 29th, 2010 8:54am

Hi Vladimir, Any updates?Frank Wang
July 1st, 2010 4:46am

Hi Vladimir, How about your question? Any updates?Frank Wang
Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2010 12:07pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics