Solved

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

Posted on 2015-01-11
3
317 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
[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
3 Comments
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 250 total points
ID: 40543320
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
ID: 40543322
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 69

Expert Comment

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

Featured Post

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.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
In-place Upgrading Dirsync to Azure AD Connect
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

726 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