Solved

Exchange Management Shell Error

Posted on 2010-08-30
8
432 Views
Last Modified: 2012-05-10
Trying to produce a report using Exchange Management Shell for mailbox statistics.

Here is what I am entering:

Get-MailboxStatistics -Database “Mailbox Database” | Sort -Property TotalItemsize | Format-Table DisplayName, LastLoggedOnUserAccount, ItemCount, @{expression={$_.totalitemsize.value.ToMB()};label=”Size(MB)”}, LastLogonTime, LastLogoffTime | Export-CSV c:\mailboxes.csv

It displays correctly in the shell, but the output is distorted and looks like below attachment.

Any help would be appreciated.



mail.JPG
0
Comment
Question by:chadkline
  • 4
  • 3
8 Comments
 
LVL 6

Expert Comment

by:craig_j_Lawrence
ID: 33563307
If you remove the format-table section, it should export to csv properly. As you have discovered, format-table is for on screen display, not for exporting to a file

Take a look at the 'one-liner' in the link, should guide you in the right direction: http://powershell.com/cs/media/p/1668.aspx

and this one show how to manipulate the data

http://aspoc.net/archives/2007/11/07/convert-the-get-mailboxstatistics-output-from-bytes-to-mb-or-gb-in-exchange-2007/

Hope this helps
Craig
0
 

Author Comment

by:chadkline
ID: 33563348
Thanks. I will try it out in the morning.
0
 
LVL 28

Accepted Solution

by:
sunnyc7 earned 500 total points
ID: 33563843
Get-MailboxStatistics -Database “Mailbox Database” | Sort -Property TotalItemsize | Format-Table DisplayName, LastLoggedOnUserAccount, ItemCount, @{expression={$_.totalitemsize.value.ToMB()};label=”Size(MB)”}, LastLogonTime, LastLogoffTime > c:\mailboxes.csv
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:chadkline
ID: 33563902
Please explain your solution sunnyc7
0
 
LVL 28

Expert Comment

by:sunnyc7
ID: 33565958
I just modified your script
0
 

Author Comment

by:chadkline
ID: 33567772
sunnyc7,

Your output is exactly what I want, however, when I open the csv file, all of the columns are in one cell.
How can this be corrected?
0
 

Author Comment

by:chadkline
ID: 33568033
Okay, here is what I did. I removed the Format Table and added Select:

Get-MailboxStatistics -Database “Mailbox Database” | Select DisplayName, LastLoggedOnUserAccount, ItemCount, @{expression={$_.totalitemsize.value.ToMB()};label=”Size(MB)”}, LastLogonTime, LastLogoffTime | Export-CSV c:\mailboxes2.csv

I got the results i wanted and in separate columns in the csv.
0
 
LVL 28

Expert Comment

by:sunnyc7
ID: 33568058
nice :)
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Email signature with pictures on iPad/iPhone 1 37
Exchange 2016 install absolute nightmare 10 46
Dynamic Distribution Group 4 24
open ost file into new machine? 7 56
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Read this checklist to learn more about the 15 things you should never include in an email signature.
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…

803 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