0 votes

I am looking for a solution to recognize in advance when the storage space of a shared mailbox is full and then a mail is sent Unfortunately, the report under Quotas, Limits and Restrictions does not provide the desired result. So far we have queried this manually via PS Script:


# Retrieve all shared mailboxes within the OU
$mailboxes = Get-Mailbox  -RecipientTypeDetails SharedMailbox

# Initiate the report
$report = @()

# Collect information for each mailbox in the OU
foreach ($mailbox in $mailboxes) {
    $mailboxUser = $mailbox.PrimarySmtpAddress

    # Retrieve mailbox statistics
    $mailboxStats = Get-MailboxStatistics -Identity $mailboxUser

    # Get the used mailbox size as a string and trim after the parentheses
    $usedSize = $mailboxStats.TotalItemSize.ToString() -replace '\s*\(.*$', ''

    # Retrieve maximum mailbox size from the quota property as a string (directly from the result)
    $maxSize = $mailbox.ProhibitSendReceiveQuota.ToString() -replace '\s*\(.*$', ''

    # Query archive size if available
    $archiveSize = "No archive available"
    if ($mailbox.ArchiveStatus -eq "Active") {
        $archiveStats = Get-MailboxStatistics -Identity "$mailboxUser" -Archive
        $archiveSize = $archiveStats.TotalItemSize.ToString() -replace '\s*\(.*$', ''
    }

    # Create report entry
    $reportEntry = @"

$mailboxUser
Used Size: $usedSize
Maximum Size: $maxSize
Archive: $archiveSize

"@

    # Add entry to the report
    $report += $reportEntry

}

# Write the entire report to a file
$reportFile = "$reportDir\SharedMailboxesReport.txt"
$report -join "`r`n" | Out-File -FilePath $reportFile -Encoding UTF8

Is there possibly a solution to query this automatically via Adaxes? Thanks!

by (530 points)

1 Answer

0 votes
by (289k points)

Hello Boris,

You can use the following script from our repository in a condition: https://www.adaxes.com/script-repository/check-mailbox-size-s450.htm. If the condition is met, the Send email notification action should be executed.

0

Hi,

thanks for the message an the link. I am looking more for a notifcation in case the size reaches 90% or is 1GB before the limit. The limit is mostly custom, so I cannot use a fix size limtit for the report.

0

Hello,

Do we understand correctly that the actual mailbox size is over 90% of the ProhibitSendReceiveQuota? Also, please, describe the desired behavior in all the possible details with live examples. For example, do you need that to be a report in Adaxes?

0

Hello.

yes I am looking for a solution if the space for shared mailboxes reaches 90% of the ProhibitSendReceiveQuota I want to get a notification. This can also be a report.

I have tried the report under image.png but it is not suitable for my purpose

0

Hello Boris,

Thank you for clarifying, but we need to know the exact desired behavior. In either case, please, provide a live example of the email/report. We just need to be sure what you need included.

0

Hello,

sorry if I have expressed myself in a misleading way here. If I use the script above I get the following report:

image.png

I would like to achieve that when the value “used size” reaches 90% of the value “max size” I can trigger a notification.

The query should be possible within an OU

0

Hello Boris,

Sorry for the confusion, but that is still very misleading. Do you want to have a custom command that can be executed on the Organizational Unit object type and send an email containing the mentioned details for all shared mailboxes that are above 90% of used storage in the target OU?

0

In the best case I would like to have a scheduled report with the condition “size above 90%” or alternatively a report “Mailbox size above 90%” which I can place on the home page in the frontend. But I am also open to any other kind of alerting when the available space of a mailbox reaches 90%

0

Hello Boris,

It is totally up to you. We just need to know how you need it to work and then see what can be done.

0

Thanks, a scheduled report that queries all mailboxes within an OU which triggers a mail notification if one or more of these mailboxes uses 90% of the available size would be great. Thanks!

0

Hello Boris,

What exactly do you mean by triggers a mail notification? If you schedule a report in Adaxes, it is the report being delivered, nothing else.

0

Hi,

yes report being delivered fits perfectly.

0

Hello Boris,

Thank you for the confirmation. What columns do you need to present (the Name one will always be there)? Please, provide a live example of the desired report.

0

Hello,

the report should include the following values:

0

Hello Boris,

Thank you for the provided example. For us to write a script that will generate the report, please, provide us with a screenshot of the Multi-server environment dialog. The dialog displays how many Adaxes services you have and what their versions are. For information on how to view it, see https://www.adaxes.com/help/MultiServerEnvironment. You can post the screenshot here or send to us at support@adaxes.com.

0

Hello,

we have only one instance running: image.png

thanks for your support

0

Hello Boris,

Thank you for all the provided details. To achieve the desired, use the below script. To execute the script, create a report with a scope and no parameters. In the script:

  • $usedSizeColumnID - Specifies the identifier of the custom column that will contain the used mailbox space in Gb.
  • $maxSizeColumnID - Specifies the identifier of the custom column that will contain the maximum mailbox size in Gb.
  • $freeSizeColumnID - Specifies the identifier of the custom column that will contain the free mailbox space in Gb.
  • $usedSizeInPercentageColumnID - Specifies the identifier of the custom column that will contain the used mailbox space in percents.
  • $archiveSizeColumnID - - Specifies the identifier of the custom column that will contain the mailbox archive size in Gb.

To obtain a report custom column identifier:

  • On the Columns tab, right-click the custom column in the Report-specific columns section.
  • In the context menu, navigate to Copy and click Column ID.
  • The column identifier will be copied to clipboard.

For details on how to schedule reports, see https://www.adaxes.com/help/ScheduleReports.

$usedSizeColumnID = "{94bd8499-088d-43c2-bd1e-e1c1b7fa9f23}" # TODO: modify me
$maxSizeColumnID = "{c19d2faa-c0f6-4071-9f81-cd461b31738b}" # TODO: modify me
$freeSizeColumnID = "{73a25196-887b-44aa-aca5-372248248e42}" # TODO: modify me
$usedSizeInPercentageColumnID = "{93cbc727-11d8-4e8a-adf5-6934469a2126}" # TODO: modify me
$archiveSizeColumnID = "{550e1ce1-e633-46fb-ae09-3941ff8c094e}" # TODO: modify me

$criteria = New-AdmCriteria "user" {mailboxType -eq "shared"}
$Context.DirectorySearcher.AddCriteria($criteria)
try
{
    $searchIterator = $Context.DirectorySearcher.ExecuteSearch()
    while ($Context.MoveNext($searchIterator))
    {
        $searchResult = $searchIterator.Current
        $user = $Context.BindToObjectBySearchResult($searchResult)

        # Get Exchange properties
        try
        {
            $mailboxParams = $user.GetMailParameters()
        }
        catch
        {
            $Context.LogMessage($_.Exception.Message, "Warning")
            continue
        }

        # Check quotas
        if ($NULL -eq $mailboxParams.StorageQuotas.ProhibitSendReceiveQuota)
        {
            continue
        }

        # Get mailbox size and max size
        $mailboxSizeGB = $mailboxParams.UsageInfo.Size.GetGBytes()
        $maxSizeGB = $mailboxParams.StorageQuotas.ProhibitSendReceiveQuota.GetGBytes()

        # Skip less than 90 percentage
        $usedSizeInPercentage = [System.Math]::Round(($mailboxSizeGB/$maxSizeGB)*100)
        if ($usedSizeInPercentage -lt 90)
        {
            continue
        }

        # Get free size
        $freeSizeGB = $maxSizeGB - $mailboxSizeGB

        # Get Archive size
        # Get properties of the 'Archiving' feature
        $archiving = $mailboxParams.MailboxFeatures.GetItemByType("ADM_EXCHANGE_MAILBOXFEATURETYPE_ARCHIVE")
        if ($archiving.Enabled -and $NULL -ne $archiving.Size)
        {
            $archiveSizeGB = $archiving.Size.GetGBytes()
        }
        else
        {
            $archiveSizeGB = $NULL
        }

        $customColumns = @{
            $usedSizeColumnID = [System.Math]::Round($mailboxSizeGB, 4)
            $maxSizeColumnID = [System.Math]::Round($maxSizeGB, 4)
            $freeSizeColumnID = [System.Math]::Round($freeSizeGB, 4)
            $usedSizeInPercentageColumnID = $usedSizeInPercentage
            $archiveSizeColumnID = [System.Math]::Round($archiveSizeGB, 4)
        }
        $Context.Items.Add($searchResult, $customColumns, $NULL)
    }
}
finally
{
    if ($searchIterator) { $searchIterator.Dispose() }
}
0

Hello Support,

Thank you very much for the time and effort you have invested, the script fulfills my requirements perfectly. :) Unfortunately it is stopping with "The pipeline has been stopped", after some minutes I have set the scope to "specific location" and "direct children", which contains ~200 Mailboxes. Any thing else I could do, to avoid the error?

image.png

0

Hello Boris,

The error occurs because executing the script takes longer than 10 minutes which is the default timeout. You can change the timeout, but it can only be done for all scripts.

Related questions

0 votes
0 answers

We currently convert user mailboxes to shared mailboxes during deprovisioning process but if the user mailbox was already a shared mailbox then the script throws an error ... user mailbox. Here is the actions of the current deprovision command: Thanks!

asked Oct 1 by Carlos (40 points)
0 votes
1 answer

So if we change the flow on the exisitng deprovision script to the above, is there a way to set a retention policy tag to the converted mailbox? Our standard retention is 90 days.

asked Sep 19 by EnbyAdmin (60 points)
0 votes
1 answer

Good afternoon, Is there a script for adding a user to an already existing Office 365 Shared Mailbox? I want to add this script onto the onboarding rules I have added already.

asked May 7 by ocanizales (60 points)
0 votes
1 answer

I'd like some help with a script to revoke a users rights to a shared mailbox upon being removed from a security group. I already have the reverse, a script that adds users to a shared mailbox, if they are a member of a group, now I just need the reverse.

asked Mar 20 by dominik.stawny (280 points)
0 votes
1 answer

We have a "Create Shared Mailbox" function which uses a custom command in PS. I've amended my PS script to created Shared Mailboxes to be inline with the V3 of Exchange ... issue? Here's the script And here's the error after using the the function once.

asked Jun 13, 2023 by Homelander90 (350 points)
3,548 questions
3,239 answers
8,232 comments
547,814 users