Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - How export-csv deals with string versus string[]

Reply
 
Old 07-13-2007   #1 (permalink)
Marco Shaw


 
 

How export-csv deals with string versus string[]

An interesting question came up regarding Exchange 2007. One of the
cmdlets returns properties that are a simply system.string, while some
other properties are system.string[].

[PS] C:\Documents and
Settings\Administrator>Get-MessageTrackingLog|select-object
recipients|export-csv c:\test.csv
[PS] C:\Documents and Settings\Administrator>gc c:\test.csv
#TYPE System.Management.Automation.PSCustomObject
Recipients
System.String[]
System.String[]
System.String[]
[PS] C:\Documents and
Settings\Administrator>Get-MessageTrackingLog|select-object
sender|export-csv c:\test.csv
[PS] C:\Documents and Settings\Administrator>gc c:\test.csv
#TYPE System.Management.Automation.PSCustomObject
Sender
Administrator@contoso.com
Administrator@contoso.com
Administrator@contoso.com
[PS] C:\Documents and Settings\Administrator>

Anyone had any idea how one can expand a system.string[] to it is
properly listed out with export-csv?

Is this a bug?

Marco

My System SpecsSystem Spec
Old 07-13-2007   #2 (permalink)
/\/\o\/\/ [MVP]


 
 

RE: How export-csv deals with string versus string[]

can you try this :

Get-MessageTrackingLog|select-object {$_.recipients} | export-csv c:\test.csv

soory can't test here but think that should work .

Greetings /\/\o\/\/

"Marco Shaw" wrote:

> An interesting question came up regarding Exchange 2007. One of the
> cmdlets returns properties that are a simply system.string, while some
> other properties are system.string[].
>
> [PS] C:\Documents and
> Settings\Administrator>Get-MessageTrackingLog|select-object
> recipients|export-csv c:\test.csv
> [PS] C:\Documents and Settings\Administrator>gc c:\test.csv
> #TYPE System.Management.Automation.PSCustomObject
> Recipients
> System.String[]
> System.String[]
> System.String[]
> [PS] C:\Documents and
> Settings\Administrator>Get-MessageTrackingLog|select-object
> sender|export-csv c:\test.csv
> [PS] C:\Documents and Settings\Administrator>gc c:\test.csv
> #TYPE System.Management.Automation.PSCustomObject
> Sender
> Administrator@contoso.com
> Administrator@contoso.com
> Administrator@contoso.com
> [PS] C:\Documents and Settings\Administrator>
>
> Anyone had any idea how one can expand a system.string[] to it is
> properly listed out with export-csv?
>
> Is this a bug?
>
> Marco
>

My System SpecsSystem Spec
Old 07-13-2007   #3 (permalink)
Marco Shaw


 
 

Re: How export-csv deals with string versus string[]

//o// [MVP] wrote:
> can you try this :
>
> Get-MessageTrackingLog|select-object {$_.recipients} | export-csv c:\test.csv
>
> soory can't test here but think that should work .


It works! Thought I had tried that, but guess I didn't...

I did this instead to retain the header title:

Get-MessageTrackingLog|select-object
@{Name="Recipients";Expression={$_.recipients}} | export-csv c:\test.csv

Thanks!

Marco
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Find a string within a variable string PowerShell
problems with $var | select-string -pattern $string -q PowerShell
Search for string in CSV and delete line if string found in line PowerShell
String PRODUCT_NAME was not found in string table Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46