Solved

exchange convert kb,mb or gb

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Enabling exchange 2013 read receipt 7 21
Ouput in html in powershell 2 19
Powershell - Script Refine - v3 8 41
Exchange 2010 Dag Setup 2 16
A procedure for exporting installed hotfix details of remote computers using powershell
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
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…
In this video we show how to create a mailbox database 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 Servers >> Data…

856 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