How to get mailbox's quota RRS feed

  • Question

  • I wan't to get a user's mailbox's quota and how many percent is used, by example:

    The used is the sum of all folders
    (inbox calendar
    outbox .....)

    but I don't know how to get it via exchange2007 webservice?
    Can anyone tell me how to do it?Thanks

    Friday, December 7, 2007 6:51 AM

All replies

  • I don't think EWS is the best approach for you.  Powershell has a script that returns the size of a mailbox or individual folders quite nicely.  Powershell also returns their quota status, but it doesn't tell you how close they are to the limit.  For example, it just tells you "UnderQuota", etc., not how much under.


    To get the quota, for a mailbox, I think you'll have to be making some Active Directory calls.  It's all stored there as properties.  But a mailbox can either have it's own quota, no quota, or inherit the mailbox store's quota setting.  By querying AD, you'll be able to find out which value to use.



    Saturday, December 8, 2007 1:59 AM
  • You can get everything you need using a combination of Exchange Management Shell Powershell cmdlets eg

    Get-mailboxstatitics will return mailbox size
    Get-mailbox will return explictly set Mailbox Quotas
    Get-mailboxdatabase will return MailStore Quotas

    So as Chris said you need to first check the UseDatabaseQuotaDefaults setting on the mailbox and then get the quota setting from the mailstore if needed. You cant pull this information from EWS or Mapi as far as i know (although annoyingly enough OWA 2007 can show you this information)

    An exmple of the powershell stuff would look like

    Code Block

     Get-Mailbox -identity user | foreach-object{
        $mbSizeDetails = get-mailboxstatistics $_.identity
        if ($_.UseDatabaseQuotaDefaults -eq $true){
            $dbsetting = get-Mailboxdatabase $_.database
            if ($dbsetting.ProhibitSendReceiveQuota -ne "unlimited"){
                $_.DisplayName + " " + $mbSizeDetails.TotalItemSize.Value.ToMB() + " " + $dbsetting.ProhibitSendReceiveQuota.Value.ToMB() + " " + "{0:P1}" -f ($mbSizeDetails.TotalItemSize.Value.ToMB()/$dbsetting.ProhibitSendReceiveQuota.Value.ToMB())
                $_.DisplayName + " " + $mbSizeDetails.TotalItemSize.Value.ToMB() + " unlimited"

        else {    
            if ($_.ProhibitSendReceiveQuota -ne "unlimited"){
                $_.DisplayName + " " + $mbSizeDetails.TotalItemSize.Value.ToMB()  + " " + $_.ProhibitSendReceiveQuota.Value.ToMB() + " " + "{0:P1}" -f ($mbSizeDetails.TotalItemSize.Value.ToMB()/$_.ProhibitSendReceiveQuota.Value.ToMB())
            else {
                $_.DisplayName + " " + $mbSizeDetails.TotalItemSize.Value.ToMB()  + " unlimited"


    Monday, December 10, 2007 2:03 AM
  • Hi,

    Glen Scales has given the solution for this..

    i hope it will work.

    KSN MCITP-EXCHANGE 2007|MCITP-2008|MCTS ----------------------------------------------------------- Please remember to click “Mark as Answer” on the post if u belive it as answer. This can be beneficial to other community members reading the thread.
    Friday, January 28, 2011 5:00 PM