locked
Report to show Current Size, Size Limits and Quota Per user RRS feed

  • Question

  • Hello, i have been asked to produce a report for our company detailing the current mailbox size, the quota limit, if the mailbox is using it, and some other bits of info (total size etc...)

    in my trawling i came accross the following script:

    Get-User -ResultSize Unlimited | Where {$_.RecipientType -eq "UserMailbox"} | Select DisplayName, Company, City | foreach {

     

    $MailboxInfo = Get-Mailbox -identity $_.displayName

    $MailboxStat = Get-MailboxStatistics -identity $_.displayName

     

    Add-Member -InputObject $_ noteProperty UseDefault $MailboxInfo.UseDatabaseQuotaDefaults

    Add-Member -InputObject $_ noteProperty WarningQuota $MailboxInfo.IssueWarningQuota

    Add-Member -InputObject $_ noteProperty SendQuota $MailboxInfo.ProhibitSendQuota

    Add-Member -InputObject $_ noteProperty SendRecieveQutoa $MailboxInfo.ProhibitSendReceiveQuota

     

    Add-Member -InputObject $_ noteProperty QuotaStatus $MailboxStat.StorageLimitStatus 

    Add-Member -InputObject $_ noteProperty TotalItems $MailboxStat.ItemCount

    Add-Member -InputObject $_ noteProperty TotalSizeMB $MailboxStat.TotalItemSize.Value.ToMB()

    Add-Member -InputObject $_ noteProperty DeleteItems $MailboxStat.DeletedItemCount

    Add-Member -InputObject $_ noteProperty DeletedSizeMB $MailboxStat.TotalDeletedItemSize.Value.ToMB() -PassThru

     

    } | Export-Csv -Path C:\MailboxSize.csv

     

    Which does most of it with the exception of the quota and also when a user is on defaults all of the WarningQuota\SendQuota\SendReceiveQuota all say "unlimited" despite the face that they are not unlimited, they are just using the defaults, we have different databases to determine the mailbox store default sizes i was wondering if anyone has come accross this and has a suggestion or possible solution.

    Thursday, October 20, 2011 1:57 PM

Answers

  • It sounds like you'll need to modify the script to read the database they're in, find the quota settings for that database, and substitute those for the quota properties if the mailbox is set to use defaults.

    I'd use a routine to read and store the quota settings from all the databases up front, and use those for the substitutions rather than re-reading the quota settings inside the foreach loop.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    • Proposed as answer by Jason LJS Monday, October 24, 2011 2:09 AM
    • Marked as answer by Jason LJS Friday, October 28, 2011 8:28 AM
    Thursday, October 20, 2011 2:19 PM

All replies

  • It sounds like you'll need to modify the script to read the database they're in, find the quota settings for that database, and substitute those for the quota properties if the mailbox is set to use defaults.

    I'd use a routine to read and store the quota settings from all the databases up front, and use those for the substitutions rather than re-reading the quota settings inside the foreach loop.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    • Proposed as answer by Jason LJS Monday, October 24, 2011 2:09 AM
    • Marked as answer by Jason LJS Friday, October 28, 2011 8:28 AM
    Thursday, October 20, 2011 2:19 PM
  • You can give a try on the following where a conditional operation has been added to check if a mailbox is using database-level size quota or mailbox-level size quota
    Get-User -ResultSize Unlimited | Where {$_.RecipientType -eq "UserMailbox"} | Select DisplayName, Company, City | foreach {
    $MailboxInfo = Get-Mailbox $_.DisplayName
    $MailboxStat = Get-MailboxStatistics $MailboxInfo
    if($MailboxInfo.UseDatabaseQuotaDefaults) {
    $MailboxDatabaseInfo = get-mailboxdatabase $MailboxInfo.database
    Add-Member -InputObject $_ noteProperty WarningQuota $MailboxDatabaseInfo.IssueWarningQuota
    Add-Member -InputObject $_ noteProperty SendQuota $MailboxDatabaseInfo.ProhibitSendQuota
    Add-Member -InputObject $_ noteProperty SendRecieveQutoa $MailboxDatabaseInfo.ProhibitSendReceiveQuota
    }else{
    Add-Member -InputObject $_ noteProperty WarningQuota $MailboxInfo.IssueWarningQuota
    Add-Member -InputObject $_ noteProperty SendQuota $MailboxInfo.ProhibitSendQuota
    Add-Member -InputObject $_ noteProperty SendRecieveQutoa $MailboxInfo.ProhibitSendReceiveQuota
    }
    Add-Member -InputObject $_ noteProperty QuotaStatus $MailboxStat.StorageLimitStatus 
    Add-Member -InputObject $_ noteProperty TotalItems $MailboxStat.ItemCount
    Add-Member -InputObject $_ noteProperty TotalSizeMB $MailboxStat.TotalItemSize.Value.ToMB()
    Add-Member -InputObject $_ noteProperty DeleteItems $MailboxStat.DeletedItemCount
    Add-Member -InputObject $_ noteProperty DeletedSizeMB $MailboxStat.TotalDeletedItemSize.Value.ToMB() -PassThru
     
    } | Export-Csv -NoTypeInformation -Path C:\MailboxSize.csv

    • Edited by shuen100 Thursday, October 20, 2011 3:06 PM
    • Proposed as answer by Jason LJS Monday, October 24, 2011 2:09 AM
    Thursday, October 20, 2011 3:06 PM
  • shuen100:

    I get this error when running it:

    Get-MailboxStatistics : Cannot convert 'System.Object[]' to the type 'Microsoft
    .Exchange.Configuration.Tasks.GeneralMailboxIdParameter' required by parameter
    'Identity'. Specified method is not supported.
    At C:\GetMailboxSize.ps1:3 char:37
    + $MailboxStat = Get-MailboxStatistics <<<<  $MailboxInfo
        + CategoryInfo          : InvalidArgument: (:) [Get-MailboxStatistics], Pa
       rameterBindingException
        + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Exchange.Managem
       ent.MapiTasks.GetMailboxStatistics

    Wednesday, October 26, 2011 10:33 PM