Solved

Get-MailboxStatistics and Get-Mailbox

Posted on 2014-09-22
4
535 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
  • 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
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…
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…

910 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

21 Experts available now in Live!

Get 1:1 Help Now