Solved

exchange convert kb,mb or gb

Posted on 2011-09-15
4
423 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

Are end users causing IT problems again?

You’ve taken the time to design and update all your end user’s email signatures, only to find out they’re messing up the HTML, changing the font and ruining the imagery. What can you do to prevent this? Find out how you can save your signatures from end users today.

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
In this video we show how to create a Contact 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 Recipients >> Contact ta…
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…

760 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

23 Experts available now in Live!

Get 1:1 Help Now