Solved

Get-MailboxStatistics and Get-Mailbox

Posted on 2014-09-22
4
594 Views
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
0
Comment
Question by:Terellion
[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
  • 2
4 Comments
 
LVL 29

Assisted Solution

by:becraig
becraig earned 250 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

0
 
LVL 16

Accepted Solution

by:
Rajitha Chimmani earned 250 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

0
 
LVL 29

Expert Comment

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

Author Comment

by:Terellion
ID: 40340981
Absolutely awesome thanks so much!!! :)
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
In this video we show how to create an email address policy 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…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

687 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