none
Exporting Powershell to formatted CSV file RRS feed

  • Question

  • Hello

    Running Powershell v2. I have the following command that pulls mailbox name and sizes for a list of users.

    But when it exports to CSV, the data is not formatted properly. What I'd like to do is have Display Name and Mailbox Size in seperate columns on the CSV file but this doesn't seem possible? When the data is exported it all appears in the same column?

    Get-content c:\LIST.txt | Get-mailbox | Foreach-object {get-mailboxstatistics -identity $_} | fl displayname, @{ expression={$_.TotalItemSize.Value.ToMB()}} > c:\export.csv
    Saturday, October 22, 2011 9:53 AM

Answers

  • select displayname, @{ expression={$_.TotalItemSize.Value.ToMB()}} | Export-Csv  c:\export.csv
    

    Saturday, October 22, 2011 9:57 AM
  • As soon as you send the results to Format-List, you lose all the detail.  That is why it isn't working.  Replace fl with select, and pipe it to csv, as Kazun has shown.
    [string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"
    Saturday, October 22, 2011 10:16 AM

All replies

  • select displayname, @{ expression={$_.TotalItemSize.Value.ToMB()}} | Export-Csv  c:\export.csv
    

    Saturday, October 22, 2011 9:57 AM
  • As soon as you send the results to Format-List, you lose all the detail.  That is why it isn't working.  Replace fl with select, and pipe it to csv, as Kazun has shown.
    [string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"
    Saturday, October 22, 2011 10:16 AM