Skip to content

Commit

Permalink
Update Invoke-CIPPStandardDeletedUserRentention.ps1
Browse files Browse the repository at this point in the history
Updated from 1 year to maximum of 10 years.
smood922 authored Dec 21, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent caf37a4 commit 3f35935
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -8,23 +8,23 @@ function Invoke-CIPPStandardDeletedUserRentention {

If ($Settings.remediate) {
try {
$body = '{"deletedUserPersonalSiteRetentionPeriodInDays": 365}'
$body = '{"deletedUserPersonalSiteRetentionPeriodInDays": 3650}'
New-GraphPostRequest -tenantid $tenant -Uri 'https://graph.microsoft.com/beta/admin/sharepoint/settings' -AsApp $true -Type PATCH -Body $body -ContentType 'application/json'

Write-LogMessage -API 'Standards' -tenant $tenant -message 'Set deleted user rentention of OneDrive to 1 year' -sev Info
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Set deleted user rentention of OneDrive to 10 years' -sev Info
} catch {
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to set deleted user rentention of OneDrive to 1 year: $($_.exception.message)" -sev Error
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to set deleted user rentention of OneDrive to 10 years: $($_.exception.message)" -sev Error
}
}
if ($Settings.alert) {
if ($CurrentInfo.deletedUserPersonalSiteRetentionPeriodInDays -eq 365) {
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Deleted user rentention of OneDrive is set to 1 year' -sev Info
if ($CurrentInfo.deletedUserPersonalSiteRetentionPeriodInDays -eq 3650) {
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Deleted user rentention of OneDrive is set to 10 years' -sev Info
} else {
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Deleted user rentention of OneDrive is not set to 1 year' -sev Alert
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Deleted user rentention of OneDrive is not set to 10 years' -sev Alert
}
}
if ($Settings.report) {
if ($CurrentInfo.deletedUserPersonalSiteRetentionPeriodInDays -eq 365) {
if ($CurrentInfo.deletedUserPersonalSiteRetentionPeriodInDays -eq 3650) {
$CurrentInfo.deletedUserPersonalSiteRetentionPeriodInDays = $true
} else {
$CurrentInfo.deletedUserPersonalSiteRetentionPeriodInDays = $false

0 comments on commit 3f35935

Please sign in to comment.