Solved

Exchange Management Shell Error

Posted on 2010-08-30
8
434 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
In-place Upgrading Dirsync to Azure AD Connect
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

856 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