Solved

exchange convert kb,mb or gb

Posted on 2011-09-15
4
427 Views
Last Modified: 2013-08-02
Hello to all the exchange powershell experts. I have this command which works great except for one thing. When I display the data it needs to be in kb or if within range mb or if bigger than this GB.

Here is what I currently have. The current way only allows me to do this one way.

get-content c:\temp\list.txt | foreach-object {get-mailboxstatistics $_ | select-object Displayname, {$_.TotalitemSize.Value.ToMB()}}

I am looking for my data to be something like this as the out put

Displayname             TotalItemSize
test1                             2kb
test2                             50mb
test3                             1.5GB

Any help would be appreciative, thanks.
0
Comment
Question by:techdrive
4 Comments
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 36548583
Hey :)

Perhaps like this. Is this what you had in mind?
Get-Content c:\temp\list.txt | Get-Mailbox | Get-MailboxStatistics | Select-Object Displayname, @{n='Size';e={
    If ($_.TotalItemSize.Value.ToBytes() -gt 1Gb) {
      "$($_.TotalItemSize.Value.ToGb())Gb"
    } ElseIf ($_.TotalItemSize.Value.ToBytes() -gt 1Mb) {
      "$($_.TotalItemSize.Value.ToMb())Mb"
    } Else {
      "$($_.TotalItemSize.Value.ToKb())Kb"
    } }}, TotalItemSize

Open in new window

Chris
0
 

Author Comment

by:techdrive
ID: 36566309
awesome thanks but one more thing. I wanted to pull the totalitemsize column


Get-Mailbox  | Get-MailboxStatistics | Select-Object Displayname, @{n='Size';e={
    If ($_.TotalItemSize -gt 1Gb) {
      "$($_.TotalItemSize )Gb"
    } ElseIf ($_.TotalItemSize -gt 1Mb) {
      "$($_.TotalItemSize )Mb"
    } Else {
      "$($_.TotalItemSize )Kb"
    } }}, TotalItemSize

Instead of the convertor I was using. Anyway we can make this happen, thanks
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
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 this video we show how to create an Address List 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 Organization >> Ad…
how to add IIS SMTP to handle application/Scanner relays into office 365.

777 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