Solved

exchange convert kb,mb or gb

Posted on 2011-09-15
4
434 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
[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
4 Comments
 
LVL 71

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

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this video we show how to create a Shared Mailbox 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 >> Sha…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

730 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