Get-MailboxStatistics and Get-Mailbox

Posted on 2014-09-22
Medium Priority
Last Modified: 2014-09-24
Hi there,

Hope you can help :)

I have a powershell script that runs daily to capture any mailboxes on Exchange 2007 that have the UseDatabaseQuotaDefaults field unticked in their mailbox properties. Command is below and works fine

Get-Mailbox -Server "Mail01" -ResultSize unlimited |Where{($_.UseDatabaseQuotaDefaults -eq $false)} | Sort-Object Name | Select-Object name,Database,ProhibitSendQuota,@{n="Actual Mailbox Size(MB)";e = {$MBXstat = Get-MailboxStatistics $_.name; $MBXstat.totalItemsize.value.toMB()}

What i'd like to run is only show mailboxes that are below 500MB AND have the UseDatabaseQuotaDefaults box unticked ($false).

Thanks so much for your help
Question by:Terellion
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
  • 2
LVL 29

Assisted Solution

becraig earned 1000 total points
ID: 40337175
Something like this should work for you:

Get-Mailbox -Server "Mail01" -ResultSize unlimited  |  Where{($_.UseDatabaseQuotaDefaults -eq $false)} | Get-MailboxStatistics Where {$_.totalItemsize.value.toMB() -lt 500MB}

Open in new window

LVL 16

Accepted Solution

Rajitha Chimmani earned 1000 total points
ID: 40337814
Correction in the above line of code. The method tomb() will convert the value to integer. So, you need to compare with an integer to get correct results

Get-Mailbox -Server "Mail01" -ResultSize unlimited  |  Where{($_.UseDatabaseQuotaDefaults -eq $false)} | Get-MailboxStatistics | Where {$_.totalItemsize.value.toMB() -lt 500}

Open in new window

LVL 29

Expert Comment

ID: 40337841
Yup  I missed removing the MB since it would be an integer comparison thanks :~)

Author Comment

ID: 40340981
Absolutely awesome thanks so much!!! :)

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
In this video we show how to create an Accepted Domain 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 Mail Flow >> Ac…
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…
Suggested Courses

741 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