Skip to content

Commit 9126252

Browse files
Feat: Add mailbox types selection for quota alerts (#2146)
Introduce a selection for mailbox types in the mailbox quota alert functionality. Frontend PR: KelvinTegelaar/CIPP#6380
2 parents 9b5bdd8 + ed577f6 commit 9126252

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Modules/CIPPAlerts/Public/Alerts/Get-CIPPAlertQuotaUsed.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function Get-CIPPAlertQuotaUsed {
1515
$Threshold = if ($InputValue.QuotaUsedQuota) { [int]$InputValue.QuotaUsedQuota } else { 90 }
1616
$ExcludedRaw = Get-CIPPTextReplacement -TenantFilter $TenantFilter -Text ([string]$InputValue.QuotaUsedExcludedMailboxes)
1717
$Excluded = @($ExcludedRaw -split ',' | ForEach-Object { $_.Trim().ToLower() } | Where-Object { $_ })
18+
$MailboxTypes = @($InputValue.QuotaUsedMailboxTypes.value | Where-Object { $_ })
1819

1920
try {
2021
$AlertData = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/reports/getMailboxUsageDetail(period='D7')?`$format=application/json&`$top=999" -tenantid $TenantFilter
@@ -27,8 +28,10 @@ function Get-CIPPAlertQuotaUsed {
2728
$OverQuota = $AlertData | ForEach-Object {
2829
if (!$_.StorageUsedInBytes -or !$_.prohibitSendReceiveQuotaInBytes) { return }
2930
if ($Excluded -contains $_.userPrincipalName.ToLower()) { return }
31+
# Report returns 'User'/'Shared' or 'UserMailbox'/'SharedMailbox' depending on tenant; normalize before matching
32+
if ($MailboxTypes.Count -gt 0 -and ($_.recipientType -replace 'Mailbox$') -notin $MailboxTypes) { return }
3033
$UsagePercent = [math]::Round(($_.storageUsedInBytes / $_.prohibitSendReceiveQuotaInBytes) * 100)
31-
if ($UsagePercent -gt $Threshold) {
34+
if ($UsagePercent -ge $Threshold) {
3235
[PSCustomObject]@{
3336
Message = "$($_.userPrincipalName): Mailbox is more than $($Threshold)% full. Mailbox is $UsagePercent% full"
3437
Owner = $_.userPrincipalName

0 commit comments

Comments
 (0)