To accomplish this task, you can use PowerShell along with Exchange Online cmdlets to monitor the size of the recoverable items folder in mailboxes. Here's a basic script outline to get you started:
powershellCopy code
# Connect to Exchange Online
$UserCredential = Get-Credential
Connect-ExchangeOnline -Credential $UserCredential
# Get a list of all mailboxes in the organization
$mailboxes = Get-Mailbox -ResultSize Unlimited
# Iterate through each mailbox
foreach ($mailbox in $mailboxes) {
$mailboxStats = Get-MailboxStatistics -Identity $mailbox.UserPrincipalName
# Check if recoverable items folder size exceeds 90 GB
if ($mailboxStats.RecoverableItemsQuota -gt 0 -and $mailboxStats.RecoverableItemsWarningQuota -gt 0) {
$recoverableItemsSize = $mailboxStats.TotalRecoverableItemsSize / 1GB
$recoverableItemsWarningQuota = $mailboxStats.RecoverableItemsWarningQuota / 1GB
if ($recoverableItemsSize -ge $recoverableItemsWarningQuota) {
# Send an email notification
$emailBody = "The recoverable items folder of mailbox $($mailbox.UserPrincipalName) has reached $($recoverableItemsSize) GB, which exceeds the warning quota."
Send-MailMessage -To "admin@example.com" -From "sender@example.com" -Subject "Recoverable Items Folder Size Warning" -Body $emailBody -SmtpServer "smtp.example.com"
}
}
}
# Disconnect from Exchange Online
Disconnect-ExchangeOnline -Confirm:$false
Before running the script, make sure you have the necessary permissions to access Exchange Online PowerShell cmdlets, and replace the placeholders such as admin@example.com
, sender@example.com
, and smtp.example.com
with your actual email addresses and SMTP server.
Also, ensure that you schedule this script to run periodically using Task Scheduler or any other scheduler tool to monitor the recoverable items folder sizes continuously.