Solved

exchange convert kb,mb or gb

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
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…
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…

863 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

20 Experts available now in Live!

Get 1:1 Help Now