How can I list mailbox sizes rounded to 2 decimal places

I am trying to get a list of mailbox sizes rounded to two decimal points. The command below works but it outputs .00 for all mailboxes. For example when I run it against my mailbox the output is 332.00, but my actual mailbox size rounded to two decimal places is 332.89.

Get-MailboxStatistics -Identity MYMAILBOX | ft @{Label = 'Total';expression = { "{0:N2}" -f $_.TotalItemSize.value.Tomb() -replace ","}}

Can someone tell me where I am going wrong with this command. Thank you
cyberleo2000Asked:
Who is Participating?
 
dicconbCommented:
Hi Cyberleo2000,

Try replacing your expression with this:

expression={[math]::round(($_.totalitemsize.tobytes() / 1MB),2)}

Cheers,
D
0
 
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Why not simply export the data to Csv and view in excel to round of to 2 decimal.

- Rancy
0
 
slidingfoxCommented:
Exactly what dicconb said, but don't forget value

Get-MailboxStatistics USERNAME | ft @{L='Total';e={[math]::round(($_.totalitemsize.value.tobytes() / 1MB),2)}}

Open in new window

0
 
cyberleo2000Author Commented:
brilliant, thank you both.
0
 
dicconbCommented:
Well spotted slidingfox, thanks!

Thanks for the points cyberleo2000,

D
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.