Changing all Exchange mailboxes to use database defaults for quota limits with PowerShell

Here’s an example of why I’ve come to love PowerShell. Under Exchange 2003, we set users’ mailbox quota limits per-user, since we initially set them ridiculously high (around 20 GB). The reason we did that was that prior to this year we actually didn’t have any quotas on user mailboxes and the average mailbox was about 9 GB. In preparation for moving Exchange to the datacenter (over our measly 5Mbps upload line) we introduced quotas and over the course of about 2 months gradually lowered the limits as people whittled away their old email until they were under the quota we had established (about 2.25 GB for the no-send limit — I forgot the rationale for that number — and 1.75 GB for the warning limit [the no-receive limit was set to about 40GB since I never wanted users to hit that limit]).

I think the quota limits Exchange 2003 would allow you to set through the UI were capped at around 2.0 GB so to set quota limits above this we used ADModify to update the mDBQuota* settings for each user directly in their AD entries.

However, now all those users have been moved to Exchange 2010 which let me easily set the quota limits on the Exchange DB to 2000 MB (warning) and 3000 MB (no-send). The problem with this was that all the users were set to override the database setting. How could I quickly set them all to use the database default once again? With PowerShell, this was simple:

First, get the list of all users not using the database defaults:
[PS] C:\Windows\system32>get-mailbox -filter { usedatabasequotadefaults -eq $false -AND recipientTypeDetails -eq 'usermailbox' }

When doing any bulk operation, always verify the list of objects you’re going to be modifying before actually doing the modification. 🙂 The first filter I created didn’t have the RecipientTypeDetails in it and included a DiscoveryMailbox, which I didn’t want to touch. The above command affects only UserMailboxes. If the list looks ok, set them all back to defaults:

[PS] C:\Windows\system32>get-mailbox -filter { usedatabasequotadefaults -eq $false -AND recipientTypeDetails -eq 'usermailbox' } | set-mailbox -UseDatabaseQuotaDefaults $true

And voilà, everyone’s back to using DB defaults (which I increased to 3000MB to celebrate not having to do any more mailbox moves any time soon).

Advertisement

8 Replies to “Changing all Exchange mailboxes to use database defaults for quota limits with PowerShell”

  1. Thanks for the write up. It might also be helpful to list how to change the quota for all mailboxes in the database.

    In the console tree, navigate to Organization Configuration > Mailbox.
    In the result pane, on the Database Management tab, select the database you want to configure.
    In the action pane, under the database name, click Properties.

    The limits are set on the Limit tab.

    1. We have 4 mailstores with different to no limits set. We would like to use this to this to revert everyone to the predefined limits, but are concerned that it could somehow backfire since we need the limits to to be different for the different departments. Am I safe in assuming that we would get the desired results with this?

  2. Exactly what I was looking for Evan, thanks very much for the scripts. In my case it also uncovered users with stupidly large mailboxe limits too (over 300gb limit!)

  3. That is impressive, I have Very limited powershell experience so when a command can be simply copy and pasted I’m excited.

    Only caveat is I didn’t realize powershell had an specific “Exchange Management Shell”.

  4. looked through so many posts that completely wasted my time and voila!!!! found this and 5 minutes later my mammouth task was completed!!!!

    Thanks a million for your help! excellent writeup and explanation great work !!!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: