Skip to content

Commit 526bea6

Browse files
committed
Tweak to account for the "Unlimited" default value
1 parent 947c269 commit 526bea6

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardMailboxRecipientLimits.ps1

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,24 @@ function Invoke-CIPPStandardMailboxRecipientLimits {
6767
if ($Plan) {
6868
$PlanMaxRecipients = $Plan.MaxRecipientsPerMessage
6969

70+
# If mailbox has "Unlimited" set but has a plan, use the plan's limit as the current limit
71+
$CurrentLimit = if ($Mailbox.RecipientLimits -eq 'Unlimited') {
72+
$PlanMaxRecipients
73+
}
74+
else {
75+
$Mailbox.RecipientLimits
76+
}
77+
7078
if ($Settings.RecipientLimit -gt $PlanMaxRecipients) {
7179
[PSCustomObject]@{
72-
Type = 'PlanIssue'
73-
Mailbox = $Mailbox
74-
PlanLimit = $PlanMaxRecipients
75-
PlanName = $Plan.DisplayName
80+
Type = 'PlanIssue'
81+
Mailbox = $Mailbox
82+
CurrentLimit = $CurrentLimit
83+
PlanLimit = $PlanMaxRecipients
84+
PlanName = $Plan.DisplayName
7685
}
7786
}
78-
elseif ($Mailbox.RecipientLimits -ne $Settings.RecipientLimit) {
87+
elseif ($CurrentLimit -ne $Settings.RecipientLimit) {
7988
[PSCustomObject]@{
8089
Type = 'ToUpdate'
8190
Mailbox = $Mailbox
@@ -95,7 +104,7 @@ function Invoke-CIPPStandardMailboxRecipientLimits {
95104
$MailboxesWithPlanIssues = $MailboxResults | Where-Object { $_.Type -eq 'PlanIssue' } | ForEach-Object {
96105
[PSCustomObject]@{
97106
Identity = $_.Mailbox.Identity
98-
CurrentLimit = $_.Mailbox.RecipientLimits
107+
CurrentLimit = $_.CurrentLimit
99108
PlanLimit = $_.PlanLimit
100109
PlanName = $_.PlanName
101110
}

0 commit comments

Comments
 (0)