You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add new PowerShell script to standardize mailbox recipient limits across tenants.
This script will help enforce consistent recipient limits for mailboxes in the CIPP platform.
Updated to use Bulk requests for more efficient handling.
Updated to take Mailbox Plans into account to ensure we are not attempting to set values higher than mailbox plans are already set at.
Tweak to account for the "Unlimited" default value
Refactor mailbox recipient limits script to improve efficiency and accuracy. Consolidated mailbox plan retrieval and updated filtering logic to ensure only relevant mailboxes are processed based on recipient limits.
(Helptext) Sets the maximum number of recipients that can be specified in the To, Cc, and Bcc fields of a message for all mailboxes in the tenant.
11
+
(DocsDescription) This standard configures the recipient limits for all mailboxes in the tenant. The recipient limit determines the maximum number of recipients that can be specified in the To, Cc, and Bcc fields of a message. This helps prevent spam and manage email flow.
if ([Int32]$Settings.RecipientLimit-lt0-or [Int32]$Settings.RecipientLimit-gt10000) {
32
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message 'MailboxRecipientLimits: Invalid RecipientLimit parameter set. Must be between 0 and 10000.'-sev Error
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Found $($MailboxesWithPlanIssues.Count) mailboxes where the requested recipient limit ($($Settings.RecipientLimit)) exceeds their mailbox plan limit. These mailboxes will not be updated."-sev Info
115
+
foreach ($Mailboxin$MailboxesWithPlanIssues) {
116
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Mailbox $($Mailbox.Identity) has plan $($Mailbox.PlanName) with maximum limit of $($Mailbox.PlanLimit)"-sev Info
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Successfully set recipient limits to $($Settings.RecipientLimit) for $($MailboxesToUpdate.Count) mailboxes"-sev Info
138
+
}
139
+
catch {
140
+
$ErrorMessage=Get-CippException-Exception $_
141
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message "Could not set recipient limits. $($ErrorMessage.NormalizedError)"-sev Error -LogData $ErrorMessage
142
+
}
143
+
}
144
+
else {
145
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message "All mailboxes already have the correct recipient limit of $($Settings.RecipientLimit)"-sev Info
146
+
}
147
+
}
148
+
149
+
# Alert
150
+
if ($Settings.alert-eq$true) {
151
+
if ($MailboxesToUpdate.Count-eq0-and$MailboxesWithPlanIssues.Count-eq0) {
152
+
Write-LogMessage-API 'Standards'-tenant $Tenant-message "All mailboxes have the correct recipient limit of $($Settings.RecipientLimit)"-sev Info
153
+
}
154
+
else {
155
+
$AlertMessage="Found $($MailboxesToUpdate.Count) mailboxes with incorrect recipient limits"
156
+
if ($MailboxesWithPlanIssues.Count-gt0) {
157
+
$AlertMessage+=" and $($MailboxesWithPlanIssues.Count) mailboxes where the requested limit exceeds their mailbox plan limit"
0 commit comments