Merging Get-MailboxStatistics and Get-MalboxDatabase cmds to retrieve fields from both cmds RRS feed

  • Question

  • Get-MailboxStatistics -Identity jlee | Select-Object StorageLimitStatus, DatabaseName, ItemCount, TotalItemSize, @{Name='IssueWarningQuota'; expression={ (Get-MailboxDatabase $_.DatabaseName).IssueWarningQuota}}

    StorageLimitStatus : BelowLimit
    DatabaseName       : Big Database
    ItemCount          : 15684
    TotalItemSize      : 2.786 GB (2,991,279,093 bytes)
    IssueWarningQuota  :

    I am really baffled because I can never retrieve the issueWarningQuota from Get-MailboxDatabase using the above script.
    $_.DatabaseName returns null and so is $_

    What did I do wrong?

    Monday, October 29, 2018 5:38 AM

All replies

  • On first sight I see nothing wrong with it.
    1. does get-mailboxdatabase "Big Database" return anything?    I could simulate it, when I run your command on my Ex2010 shell and my mailbox was already on Ex2016 -  so get-mailboxdatabase throws an error

    2. your command can return unexpected results. In your example u have to be sure, that all mailboxes has default quota settings.   If they have custom quota, the results will be wrong (as u query mailboxdatabase and not mailbox itself)

    Monday, October 29, 2018 8:24 AM
  • Hi Blue,

    Thanks for your question.

    I agree with Mekac, I can't see any wrong with your script.

    You have got DatabaseName property in your output. So "$_.Databasename" will not return null. Please try to run the script below to check the output.

    Get-MailboxStatistics -Identity jlee | Get-MailboxDatabase $_.DatabaseName| Select-Object IssueWarningQuota

    May be you need to check your exchange version.

    Get-MailboxDatabase is applied to:
    Exchange Server 2010, Exchange Server 2013, Exchange Server 2016, Exchange Server 2019

    Best Regards,


    Just do it.

    Tuesday, October 30, 2018 2:27 AM
  • <g class="gr_ gr_3 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="3" id="3">issuewarning</g> quota I see is a property of get-mailbox

    $outtbl = @()
    $users = Get-Mailbox -Identity jlee 
    $users | % {
      $x = Get-MailboxStatistics jlee| Select StorageLimitStatus, DatabaseName, ItemCount, TotalItemSize
      $t = New-Object PSObject -Property @{
        Name = $_.Name
        StorageLimitStatus = $x.StorageLimitStatus
        DatabaseName = $x.DatabaseName
        IssueWarningQuotaDB=(Get-MailboxDatabase $x.DatabaseName).IssueWarningQuota
      $outtbl += $t

    Tuesday, October 30, 2018 5:14 AM
  • The IssueWarningQuota property (and other quota values) exists on both the individual mailbox and on the mailbox database.

    If the mailbox uses the database defaults then the "UseDatabaseQuotaDefaults" will be set to $TRUE. This, however, doesn't mean that the values for those quotas, if they were previously set on the mailbox, are set to some other value. If you simply ask for, say, the IssueWarningQuota value you may still get a value even if the UserDatabaseDefaultQuotas property is set to $TRUE.

    If the UseDatabaseDefaultQuotas is $TRUE on the mailbox then the database value is used when evaluating the storage situation -- regardless of any values you might retrieve from the mailbox. If the value is set on the mailbox, and UseDatabaseDefaultQuotas is $FALSE then the mailbox values override the database quotas. If the quota value(s) isn't set on an individual mailbox the default value is "Unlimited" and the database limit may, or may not, apply depending on the mailbox's UseDatabaseDefaultQuotaLimits value.

    So, check the UseDatabaseDefaultQuotas property first. If it's $TRUE, ignore anything in the mailbox's quotas. That's the only way you'll get an accurate representation of the situation.

    Oh, and the value you may get from any currently, or previously, set quota values may be "Unlimited" (yes, a string). If you don't check for that, don't blindly use the values in any arithmetic operation. :-) 

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Tuesday, October 30, 2018 3:04 PM