Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Email Alert for OneDrive Storage that Exceed Threshold #1881

Closed
WillMSIRKit opened this issue Nov 16, 2023 · 2 comments
Closed
Labels
enhancement New feature or request no-priority

Comments

@WillMSIRKit
Copy link

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 = @"

<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> These users have more than 95% of storage used.
@@table@@
"@
# 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         = '[email protected]'
    From       = '[email protected]'
    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

}

@WillMSIRKit WillMSIRKit added enhancement New feature or request no-priority labels Nov 16, 2023
Copy link

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!".

@KelvinTegelaar
Copy link
Owner

Frs are only for sponsors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request no-priority
Projects
None yet
Development

No branches or pull requests

2 participants