[GH-ISSUE #1881] [Feature Request]: Email Alert for OneDrive Storage that Exceed Threshold #985

Closed
opened 2026-03-02 13:40:37 +03:00 by kerem · 2 comments
Owner

Originally created by @WillMSIRKit on GitHub (Nov 16, 2023).
Original GitHub issue: https://github.com/KelvinTegelaar/CIPP/issues/1881

Description of the new feature - must be an in-depth explanation of the feature you want, reasoning why, and the added benefits for MSPs as a whole.

Hi,

I was wondering if it would be possible to add in a feature that would allow us to receive an alert for all OneDrive storages when they exceed a pre-defined threshold. The alert should me an email that is sent that lists all user's OneDrive the exceed the threshold (i.e. 90 - 95%).

This would allow us to proactively catch when a user's OneDrive is getting close to full and can warn them to clean-up their OneDrive of unused files and such. This would be great for MSPs that are fully managing a client's Office 365 and the client is using their OneDrive like Sharepoint. (This would also allow MSPs to get users to swap to Sharepoint if they are using OneDrive at this capacity).

The Powershell commands provided is something that could be used for this feature request

PowerShell commands you would normally use to achieve above request

$adminUPN=""
$orgName=""
$userCredential = Get-Credential -UserName $adminUPN
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential

#Get a list of OneDrive for Business sites in the tenant sorted by the biggest consumer of quota

$ODFBSites = Get-SPOSite -IncludePersonalSite $True -Limit All -Filter "Url -like '-my.sharepoint.com/personal/'" | Select Owner, Title, URL, StorageQuota, StorageUsageCurrent | Sort
StorageUsageCurrent -Desc

$TotalODFBGBUsed = [Math]::Round(($ODFBSites.StorageUsageCurrent | Measure-Object -Sum).Sum /1024,2)

$Report = [System.Collections.Generic.List[Object]]::new()

ForEach ($Site in $ODFBSites) {

 $ReportLine   = [PSCustomObject]@{
   Owner       = $Site.Title
   Email       = $Site.Owner
   PercentUsed = [Math]::Round(($Site.StorageUsageCurrent/$Site.StorageQuota * 100),4)
   QuotaGB     = [Math]::Round($Site.StorageQuota/1024,2) 
   UsedGB      = [Math]::Round($Site.StorageUsageCurrent/1024,4)}
 $Report.Add($ReportLine) }

$over95 = @($Report | Where-Object { $_.PercentUsed -gt 95 })
if ($over95.Count) {
# create a Here-String template to use for mailing yourself
$mailTemplate = @"

<html><head> </head> These users have more than 95% of storage used.
@@TABLE@@
</html> "@
# create a nice HTML table from the data in $over95
$table = ($over95 | ConvertTo-Html -As Table -Fragment) -join [environment]::NewLine
# create a Hashtable for splatting the parameters to the Send-MailMessage cmdlet
$mailParams = @{
    To         = 'YOU@yourdomain.com'
    From       = 'YOU@yourdomain.com'
    SmtpServer = 'smtp.yourdomain.com'
    Subject    = 'Users that exceed 95% storage in OneDrive'
    Body       = $mailTemplate -replace '@@TABLE@@', $table
    BodyAsHtml = $true
    # more parameters can go here
}
# send the email
Send-MailMessage @mailParams

}

Originally created by @WillMSIRKit on GitHub (Nov 16, 2023). Original GitHub issue: https://github.com/KelvinTegelaar/CIPP/issues/1881 ### Description of the new feature - must be an in-depth explanation of the feature you want, reasoning why, and the added benefits for MSPs as a whole. Hi, I was wondering if it would be possible to add in a feature that would allow us to receive an alert for all OneDrive storages when they exceed a pre-defined threshold. The alert should me an email that is sent that lists all user's OneDrive the exceed the threshold (i.e. 90 - 95%). This would allow us to proactively catch when a user's OneDrive is getting close to full and can warn them to clean-up their OneDrive of unused files and such. This would be great for MSPs that are fully managing a client's Office 365 and the client is using their OneDrive like Sharepoint. (This would also allow MSPs to get users to swap to Sharepoint if they are using OneDrive at this capacity). The Powershell commands provided is something that could be used for this feature request ### PowerShell commands you would normally use to achieve above request $adminUPN="" $orgName="" $userCredential = Get-Credential -UserName $adminUPN Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential #Get a list of OneDrive for Business sites in the tenant sorted by the biggest consumer of quota $ODFBSites = Get-SPOSite -IncludePersonalSite $True -Limit All -Filter "Url -like '-my.sharepoint.com/personal/'" | Select Owner, Title, URL, StorageQuota, StorageUsageCurrent | Sort StorageUsageCurrent -Desc $TotalODFBGBUsed = [Math]::Round(($ODFBSites.StorageUsageCurrent | Measure-Object -Sum).Sum /1024,2) $Report = [System.Collections.Generic.List[Object]]::new() ForEach ($Site in $ODFBSites) { $ReportLine = [PSCustomObject]@{ Owner = $Site.Title Email = $Site.Owner PercentUsed = [Math]::Round(($Site.StorageUsageCurrent/$Site.StorageQuota * 100),4) QuotaGB = [Math]::Round($Site.StorageQuota/1024,2) UsedGB = [Math]::Round($Site.StorageUsageCurrent/1024,4)} $Report.Add($ReportLine) } $over95 = @($Report | Where-Object { $_.PercentUsed -gt 95 }) if ($over95.Count) { # create a Here-String template to use for mailing yourself $mailTemplate = @" <html><head> <style> body, table {font-family: sans-serif; font-size: 10pt; color: #000000;} table {border: 1px solid black; border-collapse: collapse;} th {border: 1px solid black; background: #dddddd; padding: 3px;} td {border: 1px solid black; padding: 3px;} </style> </head><body> These users have more than 95% of storage used.<br /> @@TABLE@@ <br /> </body></html> "@ # create a nice HTML table from the data in $over95 $table = ($over95 | ConvertTo-Html -As Table -Fragment) -join [environment]::NewLine # create a Hashtable for splatting the parameters to the Send-MailMessage cmdlet $mailParams = @{ To = 'YOU@yourdomain.com' From = 'YOU@yourdomain.com' SmtpServer = 'smtp.yourdomain.com' Subject = 'Users that exceed 95% storage in OneDrive' Body = $mailTemplate -replace '@@TABLE@@', $table BodyAsHtml = $true # more parameters can go here } # send the email Send-MailMessage @mailParams }
kerem 2026-03-02 13:40:37 +03:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 16, 2023):

Thank you for creating a feature request!
Your current priority is set to "No Priority". No Priority Feature requests automatically get closed in two days if a contributor does not accept the FR.

If you are a sponsor you can request an upgrade of priority. To upgrade the priority type "I would like to upgrade the priority".
If you want this feature to be integrated you can always do this yourself by checking out our contributions guide at https://docs.cipp.app/dev-documentation/contributing-to-the-code. Contributors to the CIPP project reserve the right to close feature requests at will.
If you'd like this feature request to be assigned to you, please comment "I would like to work on this please!".

<!-- gh-comment-id:1815125095 --> @github-actions[bot] commented on GitHub (Nov 16, 2023): Thank you for creating a feature request! Your current priority is set to "No Priority". No Priority Feature requests automatically get closed in two days if a contributor does not accept the FR. If you are a sponsor you can request an upgrade of priority. To upgrade the priority type "I would like to upgrade the priority". If you want this feature to be integrated you can always do this yourself by checking out our contributions guide at https://docs.cipp.app/dev-documentation/contributing-to-the-code. Contributors to the CIPP project reserve the right to close feature requests at will. If you'd like this feature request to be assigned to you, please comment "I would like to work on this please!".
Author
Owner

@KelvinTegelaar commented on GitHub (Nov 16, 2023):

Frs are only for sponsors.

<!-- gh-comment-id:1815156284 --> @KelvinTegelaar commented on GitHub (Nov 16, 2023): Frs are only for sponsors.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/CIPP#985
No description provided.