Skip to main content

Relating Mailbox sizes to Mailbox quotas

Somebody asked last week about how to query mailbox sizes and mailbox quota information for a user. This is a interesting question there’s are a lot of different methods for querying mailboxes sizes most of these are listed in this KB . With Exchange 2003 you can use WMI to pull the mailbox size from the Exchange_mailbox class there’s a sample in the Exchange SDK here. With mailbox quotas what quota information will apply to your mailbox will differ depending on how quotas have been applied to the mailbox. Quotas can come from 1 of 3 locations, from a policy applied to the mail-store, by setting the quotas on the mail store itself and from quotas set on the mailbox directly. So to work out what quotas apply to a user you first need to query the user object in AD and look at the mDBUseDefaults property (which relates to the use store defaults check box in AD Users and Computers). If this is set to true (which is default) then you need to look at the mail-store object to see if quotas have been applied to the store. After you have the mailbox quota information you can query the server via WMI to work out the mailbox size and then using a little math you can determine the percentage of the quota that’s been used for each user.

I came up with a couple of scripts that could do this based on the email address of the user. These scripts are designed to run with the users email address as a commandline parameter it does a lookup of Active directory based on the email address. Then checks the mDBUseDefaults property. If this is set to true it opens the mail-store object this mailbox is located on using the homemdb property and reads the quota information of the mail-store. If the mDBUseDefaults is set to false the quota information is read from the user object. The script then uses WMI to workout the mailbox size this is where the two scripts differ. The first one use’s a select statement with a Where clause and the second use the 5 key fields for the exchange_mailbox WMI class to do a direct connection via WMI. I thought the second method may have been quicker but it still a little slower then I’d like. The information is then echo'd out to the command-line and a little math I used to work out the percentage of the Quota used. These scripts are okay for one user but if your trying to do multiple users (like all the users on a server) this method is pretty slow. I started looking into ways to make this faster and one method that seemed to work although it has taken me most of the week to get it going is to use ADO data shaping to combine the data from the multiple datasources into one ADO recordset. I’m still working on this example but I should have something that’s post worthy by the next week. I’ve posted both the script I’ve talked about here as well as the slow server example.

Popular posts from this blog

The MailboxConcurrency limit and using Batching in the Microsoft Graph API

If your getting an error such as Application is over its MailboxConcurrency limit while using the Microsoft Graph API this post may help you understand why. Background   The Mailbox  concurrency limit when your using the Graph API is 4 as per https://docs.microsoft.com/en-us/graph/throttling#outlook-service-limits . This is evaluated for each app ID and mailbox combination so this means you can have different apps running under the same credentials and the poor behavior of one won't cause the other to be throttled. If you compared that to EWS you could have up to 27 concurrent connections but they are shared across all apps on a first come first served basis. Batching Batching in the Graph API is a way of combining multiple requests into a single HTTP request. Batching in the Exchange Mail API's EWS and MAPI has been around for a long time and its common, for email Apps to process large numbers of smaller items for a variety of reasons.  Batching in the Gr...

Sending a Message in Exchange Online via REST from an Arduino MKR1000

This is part 2 of my MKR1000 article, in this previous post  I looked at sending a Message via EWS using Basic Authentication.  In this Post I'll look at using the new Outlook REST API  which requires using OAuth authentication to get an Access Token. The prerequisites for this sketch are the same as in the other post with the addition of the ArduinoJson library  https://github.com/bblanchon/ArduinoJson  which is used to parse the Authentication Results to extract the Access Token. Also the SSL certificates for the login.windows.net  and outlook.office365.com need to be uploaded to the devices using the wifi101 Firmware updater. To use Token Authentication you need to register an Application in Azure https://msdn.microsoft.com/en-us/office/office365/howto/add-common-consent-manually  with the Mail.Send permission. The application should be a Native Client app that use the Out of Band Callback urn:ietf:wg:oauth:2.0:oob. You ...

How to test SMTP using Opportunistic TLS with Powershell and grab the public certificate a SMTP server is using

Most email services these day employ Opportunistic TLS when trying to send Messages which means that wherever possible the Messages will be encrypted rather then the plain text legacy of SMTP.  This method was defined in RFC 3207 "SMTP Service Extension for Secure SMTP over Transport Layer Security" and  there's a quite a good explanation of Opportunistic TLS on Wikipedia  https://en.wikipedia.org/wiki/Opportunistic_TLS .  This is used for both Server to Server (eg MTA to MTA) and Client to server (Eg a Message client like Outlook which acts as a MSA) the later being generally Authenticated. Basically it allows you to have a normal plain text SMTP conversation that is then upgraded to TLS using the STARTTLS verb. Not all servers will support this verb so if its not supported then a message is just sent as Plain text. TLS relies on PKI certificates and the administrative issue s that come around certificate management like expired certificates which is why ...
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.