Solved

Exchange 2013 Mailbox Size in GB with 2 decimals Export to CSV via Exchange PowerShell

Posted on 2015-01-11
3
274 Views
Last Modified: 2015-01-28
I have this code:
set-executionpolicy RemoteSigned
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
(Get-MailboxDatabase | get-mailboxstatistics | Sort-object totalitemsize -descending | select-object displayname, itemcount, @{ expression={$_.TotalItemSize.Value.ToGB()} } | convertto-csv | out-file "E:\Exports\$(get-date -format yyyy-MM-dd_hhmmss)_MBSize.csv")

Open in new window


And it runs great with the exception I can't seem to get the output to GB with 2 decimals. I've tried merging parts and pieces, trying to keep it a simple script without a bunch of variables...
0
Comment
Question by:abustraan
3 Comments
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 250 total points
Comment Utility
Take a look at this PAQ which will assit with the 2 decimal places.

Powershell 2 decimail places

Try removing the -descending for the script and run it again. When I did it without descending it worked for me.

Also, because you are exporting to a csv you can just sort the TotalItemSize column manually, as you already know.

Will.
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 250 total points
Comment Utility
This might work for you?
(Get-MailboxDatabase | get-mailboxstatistics | Sort-object totalitemsize -descending | select-object displayname, itemcount, @{ expression={$_.TotalItemSize.Value / 1GB};formatstring='N2' } | convertto-csv | out-file "E:\Exports\$(get-date -format yyyy-MM-dd_hhmmss)_MBSize.csv")

Open in new window

0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
Your don't write | convertto-csv | out-file, it's just | export-csv
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
A procedure for exporting installed hotfix details of remote computers using powershell
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…
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…

772 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

9 Experts available now in Live!

Get 1:1 Help Now