Group:  English: General ยป microsoft.public.windows.powershell
Thread: How export-csv deals with string versus string[]

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

How export-csv deals with string versus string[]
Marco Shaw <marco.shaw[ at ]_NO_SPAM_gmail.com> 13.07.2007 12:54:44
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[ at ]contoso.com
Administrator[ at ]contoso.com
Administrator[ at ]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
RE: How export-csv deals with string versus string[]
/\/\o\/\/ [MVP] 13.07.2007 15:00:00
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:

[Quoted Text]
> 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[ at ]contoso.com
> Administrator[ at ]contoso.com
> Administrator[ at ]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
>
Re: How export-csv deals with string versus string[]
Marco Shaw <marco.shaw[ at ]_NO_SPAM_gmail.com> 13.07.2007 17:18:53
//o// [MVP] wrote:
[Quoted Text]
> 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
[ at ]{Name="Recipients";Expression={$_.recipients}} | export-csv c:\test.csv

Thanks!

Marco

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net