Exchange 2010 PowerShell Export to CSV Error

Posted on 2012-08-12
Last Modified: 2012-08-12
I'm trying to run a report of mailboxes sizes in a database to export to a csv file, however when I run it, the results in the csv file appear as:

#TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData

The command I'm using is:

Get-Mailbox -database "DB04" | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, itemcount | Export-CSV C:\Users\Administrator.DOMAIN\Desktop\mailboxessize.csv

Thank you for your assistance in advance.
Question by:fireguy1125
    LVL 13

    Assisted Solution

    Here you go. This is what I use. Enjoy.

    Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName, IssueWarningQuota, ProhibitSendQuota, @{label="TotalItemSize(MB)";expression={(Get-MailboxStatistics$_).TotalItemSize.Value.ToMB()}}, @{label="ItemCount";expression={(Get-MailboxStatistics $_).ItemCount}}, Database | Export-Csv"C:\Scripts\UserMailboxSizes.csv" -NoTypeInformation
    LVL 67

    Accepted Solution

    You should use format-* only for screen output, or if you want a similar formatted content in text files. As a rule of thumb, format-* is always the last command in a pipe.
    Why? Because it destroys any additional information about the piped objects, transforming all properties into a single line consisting of strings.

    In this particular case you should replace the ft with select-object to get the expected result. You migth want to add the -NoTypeInformation switch to Expert-CSV to skip the type information (#TYPE ...), which is thought to be used for Import-CSV.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Email statistics and Mailbox database quotas You might have an interest in attaining information such as mailbox details, mailbox statistics and mailbox database details from Exchange server. At that point, knowing how to retrieve this information …
    Easy CSR creation in Exchange 2007,2010 and 2013
    This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now