Solved

Exchange Management Shell Error

Posted on 2010-08-30
8
437 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In-place Upgrading Dirsync to Azure AD Connect
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
This video discusses moving either the default database or any database to a new volume.

688 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