none
Powershell Export-CSV produces nothing but Hexadecimal results RRS feed

  • Question

  • My COde

    Get-MailboxDatabase |Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname,totalitemsize |Export-CSV C:\temp\mailboxes.csv

    If you just let it display on screen it looks fine.  Use Export-CSV and the resulting CSV file shows a series of hexadecimal numbers - see attached screen shot.

    What am I missing?

    Thursday, July 20, 2017 9:36 PM

Answers

  • Format cmdlet doesn't produce objects which can be used by most other cmdlets. In fact, Format cmdlets produce a special kind of formatting instruction that can only be consumed by four cmdlets: Out-Host, Out-Printer, Out-File, and Out-String. So once you've used a Format cmdlet, you either need to be at the end of your command-line, or you need to only use one of those four Out cmdlets.

    You can use Select-Object here instead of Format-Table

    Get-MailboxDatabase |Get-MailboxStatistics | Sort-Object totalitemsize -desc | Select-Object displayname,totalitemsize |Export-CSV C:\temp\mailboxes.csv

    Friday, July 21, 2017 8:00 AM

All replies

  • You cannot use Format-Table to export data.

    \_(ツ)_/

    Thursday, July 20, 2017 10:01 PM
    Moderator
  • Try select instead of ft.  Things like format-table are meant just for displaying to the console.

    Thursday, July 20, 2017 10:03 PM
  • Format cmdlet doesn't produce objects which can be used by most other cmdlets. In fact, Format cmdlets produce a special kind of formatting instruction that can only be consumed by four cmdlets: Out-Host, Out-Printer, Out-File, and Out-String. So once you've used a Format cmdlet, you either need to be at the end of your command-line, or you need to only use one of those four Out cmdlets.

    You can use Select-Object here instead of Format-Table

    Get-MailboxDatabase |Get-MailboxStatistics | Sort-Object totalitemsize -desc | Select-Object displayname,totalitemsize |Export-CSV C:\temp\mailboxes.csv

    Friday, July 21, 2017 8:00 AM