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() }
}